-
-
Save k0kubun/10e6d3387c9ab1b134622b2c9d76ef51 to your computer and use it in GitHub Desktop.
New version: https://gist.github.com/k0kubun/48cc6777fa0e82dfcd74bf38f4a48222
This file contains hidden or 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
require 'erb' | |
require 'shellwords' | |
methods = Integer(ARGV[0] || 1) | |
sleep_seconds = methods * 0.15 | |
loop_count = (250000000.0 / methods).to_i | |
src = ERB.new(<<-'erb', nil, '%').result(binding) | |
% methods.times do |i| | |
def call<%= i %>() nil end | |
call<%= i %>; call<%= i %>; call<%= i %>; call<%= i %>; call<%= i %>; | |
% end | |
if ENV['MJIT_ENABLE'] == 'true' | |
$stderr.puts "sleeping <%= sleep_seconds %>" | |
sleep <%= sleep_seconds %> | |
end | |
$stderr.puts "running" | |
i = 0 | |
before = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
while i < <%= loop_count %> | |
<%= methods.times.map { |i| "call#{i}; " }.join('') %> | |
i += 1 | |
end | |
after = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
puts((after - before).to_s) | |
$stderr.puts "finish\n" | |
erb | |
puts "\n```\n#{src}```\n\n" | |
results = [] | |
3.times do | |
if ENV['MJIT_ENABLE'] == 'true' | |
cmd = [RbConfig.ruby, '--disable-gems', '--jit-verbose=1', '--jit-max-cache=10000', '-e'] | |
else | |
cmd = [RbConfig.ruby, '--disable-gems', '-e'] | |
end | |
puts "+ #{cmd.shelljoin} ..." | |
result = IO.popen([*cmd, src], &:read) | |
results << result | |
puts "\n\nResult: #{result}\n\n" | |
end | |
puts "Avg: #{results.map(&:strip).map(&:to_f).inject(&:+) / results.size.to_f}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment