forked from HolyWalley/1brc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaverage_execution
More file actions
executable file
·37 lines (26 loc) · 834 Bytes
/
average_execution
File metadata and controls
executable file
·37 lines (26 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/env ruby
time_file_names = Dir['time_*.txt']
.collect { |f| f.split('_') }
.group_by { |f| f[1] } # group by ruby version
versions = time_file_names.keys
puts "Found (#{versions.size}) ruby versions: #{versions.join(', ')}"
puts
versions.each do |version|
puts "Ruby #{version} execution metrics:"
executions = []
min = 0
max = 0
avg = 0
time_file_names[version].each do |filename|
file = File.open(filename.join('_'), 'r')
executions.push file.read.split('real')[0].to_f
executions.sort!
min = executions.first
max = executions.last
avg = executions[1..-1].sum / (executions[1..-1].size.to_f)
end
puts "min = #{min}, max = #{max}, avg = #{avg}"
puts
end
measurement_lines = `wc -l measurements.txt`.split(' ')[0]
puts "while producing #{measurement_lines} lines!"