@@ -8,7 +8,7 @@ namespace :oneshot do
88 type = BenchmarkResultType . find_by ( name : 'Execution time' , unit : 'Seconds' )
99
1010 BenchmarkType . all . each do |benchmark_type |
11- unless benchmark_type . script_url . match ( %r[\A https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/] )
11+ unless benchmark_type . script_url . match ( %r[\A https://raw\ . githubusercontent\ . com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/] )
1212 next
1313 end
1414
@@ -24,12 +24,12 @@ namespace :oneshot do
2424 right_type = BenchmarkResultType . find_by! ( name : 'RSS memory usage' , unit : 'Kilobytes' )
2525
2626 BenchmarkType . all . each do |benchmark_type |
27- unless benchmark_type . script_url . match ( %r[\A https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/] )
27+ unless benchmark_type . script_url . match ( %r[\A https://raw\ . githubusercontent\ . com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/] )
2828 next
2929 end
3030
3131 original_type = BenchmarkType . where . not ( id : benchmark_type . id ) . find_by ( category : benchmark_type . category )
32- if original_type . nil? || !original_type . script_url . match ( %r[\A https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmarks/bm_] )
32+ if original_type . nil? || !original_type . script_url . match ( %r[\A https://raw\ . githubusercontent\ . com/ruby-bench/ruby-bench-suite/master/ruby/benchmarks/bm_] )
3333 next
3434 end
3535
@@ -46,4 +46,37 @@ namespace :oneshot do
4646 BenchmarkType . where ( category : 'file_chmod' ) . destroy_all
4747 BenchmarkType . where ( category : 'file_rename' ) . destroy_all
4848 end
49+
50+ desc 'Convert time to ips for .rb benchmark'
51+ task rb_time2ips : :environment do
52+ time_result_type = BenchmarkResultType . find_by! ( name : 'Execution time' , unit : 'Seconds' )
53+ ips_result_type = BenchmarkResultType . find_by! ( name : 'Iteration per second' , unit : 'i/s' )
54+
55+ BenchmarkType . all . each do |benchmark_type |
56+ unless benchmark_type . script_url . match ( %r[\A https://raw\. githubusercontent\. com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/.+\. rb] )
57+ next
58+ end
59+
60+ original_type = BenchmarkType . where . not ( id : benchmark_type . id ) . find_by ( category : benchmark_type . category )
61+ if original_type . nil? || !original_type . script_url . match ( %r[\A https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmarks/bm_] )
62+ next
63+ end
64+
65+ print "benchmark_type: #{ benchmark_type . category } "
66+ original_type . benchmark_runs . where ( benchmark_result_type : time_result_type ) . find_in_batches do |benchmark_runs |
67+ benchmark_runs . each do |benchmark_run |
68+ result = { }
69+ benchmark_run . result . each do |key , value |
70+ result [ key ] = 1.0 / Float ( value )
71+ end
72+ benchmark_run . result = result
73+ benchmark_run . benchmark_result_type = ips_result_type
74+ end
75+
76+ print '.'
77+ BenchmarkRun . import! ( benchmark_runs , on_duplicate_key_update : [ :result , :benchmark_result_type_id ] )
78+ end
79+ puts
80+ end
81+ end
4982end
0 commit comments