2019-06-25 08:11:06 -04:00
|
|
|
#!/usr/bin/env ruby
|
2021-02-12 07:09:02 -05:00
|
|
|
# frozen_string_literal: true
|
2019-06-25 08:11:06 -04:00
|
|
|
|
2022-02-28 13:14:03 -05:00
|
|
|
abort "usage: #{__FILE__} <memory_bundle_mem_file_name_prefix> <test_count>" unless ARGV.length == 2
|
|
|
|
memory_bundle_mem_file_name_prefix = ARGV.first
|
|
|
|
test_count = ARGV.last.to_i
|
2019-06-25 08:11:06 -04:00
|
|
|
|
2022-02-28 13:14:03 -05:00
|
|
|
results = []
|
|
|
|
(1..test_count).each do |i|
|
|
|
|
report_filename = "#{memory_bundle_mem_file_name_prefix}#{i}.txt"
|
2019-06-25 08:11:06 -04:00
|
|
|
|
2022-02-28 13:14:03 -05:00
|
|
|
stats = nil
|
|
|
|
File.foreach(report_filename).detect do |line|
|
|
|
|
stats = /TOP: (?<total_mibs_str>.*) MiB/.match(line)
|
|
|
|
end
|
|
|
|
abort 'failed to process the benchmark output' unless stats
|
2019-06-25 08:11:06 -04:00
|
|
|
|
2022-02-28 13:14:03 -05:00
|
|
|
total_mibs = stats[:total_mibs_str].to_f
|
|
|
|
results << total_mibs
|
|
|
|
end
|
|
|
|
|
|
|
|
res = results.sort
|
|
|
|
median = (res[(test_count - 1) / 2] + res[test_count / 2]) / 2.0
|
|
|
|
|
|
|
|
METRIC_NAME = "total_memory_used_by_dependencies_on_boot_prod_env_mb"
|
|
|
|
|
|
|
|
puts "# TYPE #{METRIC_NAME} gauge"
|
|
|
|
puts "# UNIT #{METRIC_NAME} mebibytes"
|
|
|
|
puts "#{METRIC_NAME} #{median.round(1)}"
|