bench.rb # -*- coding: utf-8 -*- rv = ARGV[0] cashmode = ARGV[1] url_list = [ "/#{rv} ", "/#{rv}/projects ", "/#{rv}/projects/sscope ", "/#{rv}/issues?per_page=200 ", "/#{rv}/issues/1 ", "/#{rv}/issues/47548 ", "/#{rv}/issues/51782 ", "/#{rv}/projects/its-issues/wiki " ] puts "--- Environment ---" puts `httpd -version` puts `ruby -v --yjit ; ruby -v --mjit ; ruby -v --rjit` puts `gem list --local passenger` puts `export RAILS_ENV=production; /var/lib/its/#{rv}/script/about` puts `export RAILS_ENV=production; /var/lib/its/#{rv}/bin/about` puts `export RAILS_ENV=production; cd /var/lib/its/#{rv}; bundle list` ti = 5 result = [] url_list.each { |url| rate_avg = 0 ms_avg = 0 puts "--- #{url} ---" ti.times { res = `httperf --hog --server=localhost --port=80 -- uri=#{url} --num-conns 2 --num-calls 10 2> /dev/null | grep 'Request rate:' | awk '{print$3,$5}' | sed -e 's/(//'` num = res.split(' ').map{|s| s.to_f} puts " rate: #{num[0]} req/s #{num[1]} ms/req" rate_avg += num[0] ms_avg += num[1] sleep 0.2 } rate_avg = (rate_avg/ti).round(1) ms_avg = (ms_avg/ti).round(1) result << [rate_avg, ms_avg] puts " AVG: #{rate_avg} req/s #{ms_avg} ms/req" } rate_avg_total = (result.transpose[0].inject(:+)).round(1) ms_avg_total = (result.transpose[1].inject(:+)).round(1) puts "-------------------------" result.size.times { |r| puts "#{r+1} ¥t #{url_list[r]} ¥t #{result[r][0]} ¥t #{result[r][1]}" } puts "#{cashmode} ¥t Total ¥t #{rate_avg_total} ¥t #{ms_avg_total}" puts "-------------------------" result.size.times { |r| puts " AVG Rate: #{result[r][0]} req/s (#{result[r][1]} ms/req)" }