Skip to content

Commit 0e30643

Browse files
committed
Add oneshot:normalize_rss
1 parent 56910a4 commit 0e30643

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/tasks/temporary/oneshot.rake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
module RubybenchOneshot
2+
class << self
3+
end
4+
end
5+
16
namespace :oneshot do
27
desc 'Remove duplicated commit'
38
task remove_duplicates: :environment do
@@ -17,4 +22,27 @@ namespace :oneshot do
1722
end
1823
end
1924
end
25+
26+
desc 'Resolve legacy typo'
27+
task normalize_rss: :environment do
28+
wrong_type = BenchmarkResultType.find_by!(name: 'RSS memory usage', unit: 'Kilobtyes')
29+
right_type = BenchmarkResultType.find_by!(name: 'RSS memory usage', unit: 'Kilobytes')
30+
31+
BenchmarkType.all.each do |benchmark_type|
32+
unless benchmark_type.script_url.match(%r[\Ahttps://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/])
33+
next
34+
end
35+
36+
original_type = BenchmarkType.where.not(id: benchmark_type.id).find_by(category: benchmark_type.category)
37+
if original_type.nil? || !original_type.script_url.match(%r[\Ahttps://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmarks/bm_])
38+
next
39+
end
40+
41+
puts "benchmark_type: #{benchmark_type.id}"
42+
original_type.benchmark_runs.where(benchmark_result_type: wrong_type).update_all(
43+
benchmark_result_type_id: right_type.id,
44+
benchmark_type_id: benchmark_type.id,
45+
)
46+
end
47+
end
2048
end

0 commit comments

Comments
 (0)