@@ -132,13 +132,13 @@ namespace :oneshot do
132
132
end
133
133
end
134
134
135
- desc 'Remove invalid meteor '
136
- task remove_meteor : :environment do
135
+ desc 'Remove invalid erb '
136
+ task remove_erb : :environment do
137
137
time_result_type = BenchmarkResultType . find_by! ( name : 'Execution time' , unit : 'Seconds' )
138
138
ips_result_type = BenchmarkResultType . find_by! ( name : 'Iteration per second' , unit : 'i/s' )
139
139
140
- BenchmarkType . where ( category : 'so_meteor_contest' ) . each do |benchmark_type |
141
- unless benchmark_type . script_url . match ( %r[\A https://raw\. githubusercontent\. com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/.+\. rb \z ] )
140
+ BenchmarkType . where ( category : [ 'app_erb' , 'erb_render' ] ) . each do |benchmark_type |
141
+ unless benchmark_type . script_url . match ( %r[\A https://raw\. githubusercontent\. com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/.+\. yml \z ] )
142
142
next
143
143
end
144
144
@@ -149,4 +149,78 @@ namespace :oneshot do
149
149
original_type . benchmark_runs . where ( benchmark_result_type : time_result_type ) . delete_all
150
150
end
151
151
end
152
+
153
+ desc 'Convert vm1 to ips'
154
+ task vm1 : :environment do
155
+ time_result_type = BenchmarkResultType . find_by! ( name : 'Execution time' , unit : 'Seconds' )
156
+ ips_result_type = BenchmarkResultType . find_by! ( name : 'Iteration per second' , unit : 'i/s' )
157
+
158
+ BenchmarkType . all . each do |benchmark_type |
159
+ unless benchmark_type . script_url . match ( %r[\A https://raw\. githubusercontent\. com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/vm1_.+\. yml\z ] )
160
+ next
161
+ end
162
+
163
+ original_type = BenchmarkType . where . not ( id : benchmark_type . id ) . find_by ( category : benchmark_type . category )
164
+ if original_type . nil? || !original_type . script_url . match ( %r[\A https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmarks/bm_] )
165
+ next
166
+ end
167
+
168
+ print "benchmark_type: #{ benchmark_type . category } "
169
+ original_type . benchmark_runs . where ( benchmark_result_type : time_result_type ) . find_in_batches do |benchmark_runs |
170
+ benchmark_runs . each do |benchmark_run |
171
+ result = { }
172
+ benchmark_run . result . each do |key , value |
173
+ result [ key ] = 30000000.0 / Float ( value )
174
+ end
175
+ benchmark_run . result = result
176
+ benchmark_run . benchmark_result_type = ips_result_type
177
+ end
178
+
179
+ print '.'
180
+ begin
181
+ BenchmarkRun . import! ( benchmark_runs , on_duplicate_key_update : [ :result , :benchmark_result_type_id ] )
182
+ rescue ActiveRecord ::RecordInvalid => e
183
+ puts "#{ e . class } : #{ e . message } "
184
+ end
185
+ end
186
+ puts
187
+ end
188
+ end
189
+
190
+ desc 'Convert vm2 to ips'
191
+ task vm2 : :environment do
192
+ time_result_type = BenchmarkResultType . find_by! ( name : 'Execution time' , unit : 'Seconds' )
193
+ ips_result_type = BenchmarkResultType . find_by! ( name : 'Iteration per second' , unit : 'i/s' )
194
+
195
+ BenchmarkType . all . each do |benchmark_type |
196
+ unless benchmark_type . script_url . match ( %r[\A https://raw\. githubusercontent\. com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/vm2_.+\. yml\z ] )
197
+ next
198
+ end
199
+
200
+ original_type = BenchmarkType . where . not ( id : benchmark_type . id ) . find_by ( category : benchmark_type . category )
201
+ if original_type . nil? || !original_type . script_url . match ( %r[\A https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmarks/bm_] )
202
+ next
203
+ end
204
+
205
+ print "benchmark_type: #{ benchmark_type . category } "
206
+ original_type . benchmark_runs . where ( benchmark_result_type : time_result_type ) . find_in_batches do |benchmark_runs |
207
+ benchmark_runs . each do |benchmark_run |
208
+ result = { }
209
+ benchmark_run . result . each do |key , value |
210
+ result [ key ] = 6000000.0 / Float ( value )
211
+ end
212
+ benchmark_run . result = result
213
+ benchmark_run . benchmark_result_type = ips_result_type
214
+ end
215
+
216
+ print '.'
217
+ begin
218
+ BenchmarkRun . import! ( benchmark_runs , on_duplicate_key_update : [ :result , :benchmark_result_type_id ] )
219
+ rescue ActiveRecord ::RecordInvalid => e
220
+ puts "#{ e . class } : #{ e . message } "
221
+ end
222
+ end
223
+ puts
224
+ end
225
+ end
152
226
end
0 commit comments