@@ -53,7 +53,55 @@ namespace :oneshot do
5353 ips_result_type = BenchmarkResultType . find_by! ( name : 'Iteration per second' , unit : 'i/s' )
5454
5555 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] )
56+ unless benchmark_type . script_url . match ( %r[\A https://raw\. githubusercontent\. com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/.+\. rb\z ] )
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+ begin
78+ BenchmarkRun . import! ( benchmark_runs , on_duplicate_key_update : [ :result , :benchmark_result_type_id ] )
79+ rescue ActiveRecord ::RecordInvalid => e
80+ puts "#{ e . class } : #{ e . message } "
81+ end
82+ end
83+ puts
84+ end
85+ end
86+
87+ desc 'Convert time to ips for some .yml'
88+ task yml_time2ips : :environment do
89+ time_result_type = BenchmarkResultType . find_by! ( name : 'Execution time' , unit : 'Seconds' )
90+ ips_result_type = BenchmarkResultType . find_by! ( name : 'Iteration per second' , unit : 'i/s' )
91+
92+ list = [
93+ 'require_thread.yml' ,
94+ 'require.yml' ,
95+ 'so_count_words.yml' ,
96+ 'so_k_nucleotide.yml' ,
97+ 'so_reverse_complement.yml' ,
98+ ]
99+
100+ BenchmarkType . all . each do |benchmark_type |
101+ unless benchmark_type . script_url . match ( %r[\A https://raw\. githubusercontent\. com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/.+\. yml\z ] )
102+ next
103+ end
104+ unless list . any? { |str | benchmark_type . script_url . end_with? ( str ) }
57105 next
58106 end
59107
0 commit comments