require 'benchmark' ENV['MODE'] = 'c' $suite = { :suite_insert_one => [ :test_insert_one, :test_insert_one_safe ], :suite_insert_many => [ :test_insert_many, :test_insert_many_safe ], :suite_find => [ :test_find_one, :test_find_many ], :suite_nest => [ :test_insert_one_nest_full, :test_find_one_nest_full ], } $date = Time.now.strftime('%Y%m%d-%H%M') def suite_series_name(suite) "exp_series_#{suite}_#{ENV['MODE']}" end def suite_file_name(suite) suite_series_name(suite) + '.js' end def suite_file_name_temp(suite) suite_file_name(suite) + '.tmp' end task :default => [:c, :ruby] task :c do ENV['MODE'] = 'c' $suite.each_key do |key| Rake::Task[key].invoke end end task :ruby do ENV['MODE'] = 'ruby' $suite.each_key do |suite| Rake::Task[suite].execute end end $suite.each do |suite, tests| tests.each do |t| task t do sh "ruby exp_series.rb --file #{suite_file_name_temp(suite)} --mode #{ENV['MODE']} --tag #{suite} -- --name #{t}" end end desc "#{suite} - #{$suite[suite].join(', ')}" task suite do |t| File.open(suite_file_name_temp(suite), 'w'){|f| f.puts("#{suite_series_name(suite)} = [")} btms = Benchmark.measure do $suite[suite].each do |pre| Rake::Task[pre].execute end end File.open(suite_file_name_temp(suite), 'a'){|f| f.puts("]; // #{(btms.real/60.0).round} minutes")} sh "mv #{suite_file_name_temp(suite)} #{suite_file_name(suite)}" end end task :clobber do sh "rm -f exp_series_suite_*.js" end