# VM checking and benchmarking coderequire './rbconfig'require 'fileutils'require 'pp'Ruby = ENV['RUBY'] || RbConfig.ruby#OPTIONS = %w{opt-direct-threaded-codeopt-basic-operationsopt-operands-unificationopt-instructions-unificationopt-inline-method-cacheopt-stack-caching}.map{|opt|'--disable-' + opt}opts = OPTIONS.dupConfigs = OPTIONS.map{|opt|o = opts.dupopts.delete(opt)o} + [[]]pp Configs if $DEBUGdef exec_cmd(cmd)puts cmdunless system(cmd)p cmdraise "error"endenddef dirname idx"ev-#{idx}"enddef buildConfigs.each_with_index{|config, idx|dir = dirname(idx)FileUtils.rm_rf(dir) if FileTest.exist?(dir)Dir.mkdir(dir)FileUtils.cd(dir){exec_cmd("#{Ruby} ../extconf.rb " + config.join(" "))exec_cmd("make clean test-all")}}enddef checkConfigs.each_with_index{|c, idx|puts "= #{idx}"system("#{Ruby} -r ev-#{idx}/yarvcore -e 'puts YARVCore::OPTS'")}enddef bench_each idxputs "= #{idx}"5.times{|count|print countFileUtils.cd(dirname(idx)){exec_cmd("make benchmark OPT=-y ITEMS=#{ENV['ITEMS']} > ../b#{idx}-#{count}")}}putsenddef bench# return bench_each(6)Configs.each_with_index{|c, idx|bench_each idx}enddef parse_result dataflag = falsestat = []data.each{|line|if flagif /(\w+)\t([\d\.]+)/ =~ linestat << [1ドル, 2ドル.to_f]elseraise "not a data"endendif /benchmark summary/ =~ lineflag = trueend}statenddef calc_each datadata.sort!data.pop # remove maxdata.shift # remove mindata.inject(0.0){|res, e|res += e} / data.sizeenddef calc_stat statsstats[0].each_with_index{|e, idx|bm = e[0]vals = stats.map{|st|st[idx][1]}[bm, calc_each(vals)]}enddef stattotal = []Configs.each_with_index{|c, idx|stats = []5.times{|count|file = "b#{idx}-#{count}"# p fileopen(file){|f|stats << parse_result(f.read)}}# merge statstotal << calc_stat(stats)total}# pp totaltotal[0].each_with_index{|e, idx|# print "#{e[0]}\t"total.each{|st|print st[idx][1], "\t"}puts}endARGV.each{|cmd|case cmdwhen 'build'buildwhen 'check'checkwhen 'bench'benchwhen 'stat'statelseraiseend}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。