-
-
Save ysbaddaden/74c27148dc0ecfb7e6f2145caa65a2f2 to your computer and use it in GitHub Desktop.
Run crystal MT benchmark with 1 to 128 threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = Hash(Int32, Array(Float64)).new | |
class Array | |
def avg | |
size > 0 ? sum / size : 0 | |
end | |
end | |
[1, 2, 4, 8, 12, 16, 32, 64, 128].each do |i| | |
print "running: MT:#{i}...\r" | |
results = [] of String | |
10.times do | |
results << `CRYSTAL_WORKERS=#{i} ./#{ARGV[0]}` | |
end | |
data[i] = results.compact_map do |result| | |
if result =~ /00:00:(\d\d\.\d+)/ | |
$1.to_f | |
end | |
end.sort! | |
end | |
puts | |
data.each do |_, results| | |
puts (results.avg * 1000).to_i | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment