## ## $Rev: 21 $ ## $Release: 2.1.0 $ ## copyright(c) 2006 kuwata-lab all rights reserved. ## require 'eruby' require 'erb' require 'stringio' require 'erubis' require 'erubis/engine/enhanced' require 'erubis/engine/optimized' require 'erubis/tiny' require 'erubybench-lib' ## default values filename = 'erubybench.rhtml' datafile = 'erubybench.yaml' n = 10000 ## usage def usage(n, filename, datafile) s = "Usage: ruby #{$0} [-h] [-n N] [-f file] [-d file] [testname ...]\n" s << " -h : help\n" s << " -n N : number of times to loop (default #{n})\n" s << " -f file : eruby filename (default '#{filename}')\n" s << " -d file : data filename (default '#{datafile}')\n" return s end ## parse command-line options flag_help = false flag_all = false targets = nil test_type = nil compiler_name = 'ErubisOptimized' while !ARGV.empty? && ARGV[0][0] == ?- opt = ARGV.shift case opt when '-n' ; n = ARGV.shift.to_i when '-f' ; filename = ARGV.shift when '-d' ; datafile = ARGV.shift when '-h', '--help' ; flag_help = true when '-A' ; test_all = true when '-C' ; compiler_name = ARGV.shift when '-t' ; test_type = ARGV.shift else ; raise "#{opt}: invalid option." end end puts "** n=#{n.inspect}, filename=#{filename.inspect}, datafile=#{datafile.inspect}" ## help if flag_help puts usage(n, filename, datafile) exit() end ## load data file require 'yaml' ydoc = YAML.load_file(datafile) data = [] ydoc['data'].each do |hash| data << hash.inject({}) { |h, t| h[t[0].intern] = t[1]; h } #h = {}; hash.each { |k, v| h[k.intern] = v } ; data << h end data = data.sort_by { |h| h[:code] } #require 'pp'; pp data ## open /dev/null $devnull = File.open("/dev/null", 'w') ## test definitions testdefs_str = <