@@ -8,7 +8,7 @@ namespace :oneshot do
8
8
type = BenchmarkResultType . find_by ( name : 'Execution time' , unit : 'Seconds' )
9
9
10
10
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/] )
12
12
next
13
13
end
14
14
@@ -24,12 +24,12 @@ namespace :oneshot do
24
24
right_type = BenchmarkResultType . find_by! ( name : 'RSS memory usage' , unit : 'Kilobytes' )
25
25
26
26
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/] )
28
28
next
29
29
end
30
30
31
31
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_] )
33
33
next
34
34
end
35
35
@@ -46,4 +46,37 @@ namespace :oneshot do
46
46
BenchmarkType . where ( category : 'file_chmod' ) . destroy_all
47
47
BenchmarkType . where ( category : 'file_rename' ) . destroy_all
48
48
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
49
82
end
0 commit comments