mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Share warmup logic across MJIT benchmarks
This commit is contained in:
parent
faf93e4545
commit
4c5780e51e
5 changed files with 38 additions and 30 deletions
34
benchmark/lib/benchmark_driver/runner/mjit.rb
Normal file
34
benchmark/lib/benchmark_driver/runner/mjit.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
require 'benchmark_driver/struct'
|
||||
require 'benchmark_driver/metric'
|
||||
require 'erb'
|
||||
|
||||
# A runner to measure after-JIT performance easily
|
||||
class BenchmarkDriver::Runner::Mjit < BenchmarkDriver::Runner::Ips
|
||||
# JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
|
||||
Job = Class.new(BenchmarkDriver::DefaultJob)
|
||||
|
||||
# Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
|
||||
JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC]).extend(Module.new{
|
||||
def parse(**)
|
||||
jobs = super
|
||||
jobs.map do |job|
|
||||
job = job.dup
|
||||
job.prelude = "#{job.prelude}\n#{<<~EOS}"
|
||||
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
|
||||
__bmdv_ruby_i = 0
|
||||
while __bmdv_ruby_i < 10000 # jit_min_calls
|
||||
#{job.script}
|
||||
__bmdv_ruby_i += 1
|
||||
end
|
||||
RubyVM::MJIT.pause # compile
|
||||
#{job.script}
|
||||
RubyVM::MJIT.resume; RubyVM::MJIT.pause # recompile
|
||||
#{job.script}
|
||||
RubyVM::MJIT.resume; RubyVM::MJIT.pause # recompile 2
|
||||
end
|
||||
EOS
|
||||
job
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue