1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#!/usr/bin/env ruby
# encoding: utf-8
# frozen_string_literal: true
# Master benchmark runner
# Usage: ruby benchmarks/run_all.rb
require 'fileutils'
BENCHMARK_DIR = File.dirname(__FILE__)
RESULTS_DIR = File.join(BENCHMARK_DIR, "results")
FileUtils.mkdir_p(RESULTS_DIR)
benchmarks = %w[
pack_unpack.rb
frame_encoding.rb
table_encoding.rb
method_encoding.rb
]
timestamp = Time.now.strftime("%Y%m%d_%H%M%S")
ruby_version = RUBY_VERSION.gsub('.', '_')
results_file = File.join(RESULTS_DIR, "benchmark_#{ruby_version}_#{timestamp}.txt")
puts "=" * 80
puts "AMQ-Protocol Benchmark Suite"
puts "=" * 80
puts "Ruby: #{RUBY_DESCRIPTION}"
puts "Time: #{Time.now}"
puts "Results will be saved to: #{results_file}"
puts "=" * 80
puts
File.open(results_file, 'w') do |f|
f.puts "AMQ-Protocol Benchmark Results"
f.puts "Ruby: #{RUBY_DESCRIPTION}"
f.puts "Time: #{Time.now}"
f.puts "=" * 80
f.puts
benchmarks.each do |benchmark|
benchmark_path = File.join(BENCHMARK_DIR, benchmark)
if File.exist?(benchmark_path)
puts "\n>>> Running #{benchmark}..."
puts
output = `ruby #{benchmark_path} 2>&1`
puts output
f.puts ">>> #{benchmark}"
f.puts output
f.puts
else
puts "Warning: #{benchmark_path} not found, skipping..."
end
end
end
puts
puts "=" * 80
puts "Benchmark complete! Results saved to: #{results_file}"
puts "=" * 80
|