Skip to content

Instantly share code, notes, and snippets.

@ysbaddaden
Created February 13, 2024 09:35
Show Gist options
  • Save ysbaddaden/74c27148dc0ecfb7e6f2145caa65a2f2 to your computer and use it in GitHub Desktop.
Save ysbaddaden/74c27148dc0ecfb7e6f2145caa65a2f2 to your computer and use it in GitHub Desktop.
Run crystal MT benchmark with 1 to 128 threads
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