Skip to content

Commit bc27c1c

Browse files
committed
Get harness-chain working
To use, do: NO_VIEWER=1 HARNESS_CHAIN="vernier,ractor" ruby run_benchmarks.rb --harness=chain --skip-yjit psych-load This runs vernier profiling for a ractor benchmark. You can also use perf like this, but it's untested right now.
1 parent 467fc19 commit bc27c1c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

harness-chain/harness.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
require_relative '../harness/harness-common'
22

3+
# Ex: HARNESS_CHAIN="vernier,ractor"
4+
# Wraps the ractor harness in ther vernier harness
35
CHAIN = ENV['HARNESS_CHAIN'].to_s.split(',')
46
CHAIN.reject! { |el| el.to_s.strip.empty? }
57
if CHAIN.size < 2
68
$stderr.puts "You need to chain at least 2 harnesses. Exiting."
79
exit 1
810
end
911

12+
if CHAIN.include?("vernier") && CHAIN.last != "vernier"
13+
require_relative "../harness/harness-extra"
14+
def run_enough_to_profile(n, **kwargs, &block)
15+
block.call
16+
end
17+
end
18+
19+
$current_harness = nil
20+
$benchmark_methods = []
21+
22+
class Object
23+
def self.method_added(name)
24+
if name == :run_benchmark && $current_harness
25+
$benchmark_methods << [$current_harness, Object.instance_method(name)]
26+
end
27+
end
28+
end
29+
1030
def run_benchmark(n, **kwargs, &block)
1131
CHAIN.each do |h|
1232
begin
1333
path = "../harness-#{h}/harness"
34+
$current_harness = h
1435
require_relative path
1536
rescue LoadError => e
1637
if e.path == path
@@ -20,4 +41,12 @@ def run_benchmark(n, **kwargs, &block)
2041
raise
2142
end
2243
end
44+
procs = [block]
45+
$benchmark_methods.reverse_each do |harness_name, harness_method|
46+
prok = procs.pop
47+
procs << proc { harness_method.bind(self).call(n, **kwargs, &prok) }
48+
end
49+
raise "Bad logic: #{procs.size}" unless procs.size == 1
50+
result = procs.last.call
51+
result || return_results([0], [1.0])
2352
end

0 commit comments

Comments
 (0)