Skip to content

Commit 77ed03a

Browse files
committed
Prepare to convert time -> ips
1 parent 8a6a9f6 commit 77ed03a

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

app/views/repos/_commits_chart.html.haml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
- tick_interval = (@display_count / 4) - 1
1111

1212
- charts.each do |chart|
13+
- next if chart.categories.nil? # TODO: clean up legacy records later
14+
1315
%h2.l-align-center
1416
= t('repos.commits.graph_title', graph_name: benchmark.category.humanize,
1517
type: chart.benchmark_result_type.name)

lib/tasks/temporary/oneshot.rake

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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[\Ahttps://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/])
11+
unless benchmark_type.script_url.match(%r[\Ahttps://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[\Ahttps://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmark/])
27+
unless benchmark_type.script_url.match(%r[\Ahttps://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[\Ahttps://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/ruby/benchmarks/bm_])
32+
if original_type.nil? || !original_type.script_url.match(%r[\Ahttps://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[\Ahttps://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[\Ahttps://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
4982
end

0 commit comments

Comments
 (0)