|
2 | 2 | # frozen_string_literal: true |
3 | 3 |
|
4 | 4 | require 'fileutils' |
5 | | -require 'json' |
6 | 5 | require 'optparse' |
7 | 6 | require 'tmpdir' |
8 | 7 | require 'logger' |
|
12 | 11 | GitRef = Struct.new(:ref, :commit_hash) |
13 | 12 |
|
14 | 13 | RUBIES_DIR = File.join(Dir.home, '.zjit-diff') |
15 | | -RESULTS_CACHE_DIR = File.join(Dir.home, '.zjit-diff', 'results') |
16 | 14 | BEFORE_NAME = 'ruby-zjit-before' |
17 | 15 | AFTER_NAME = 'ruby-zjit-after' |
18 | 16 |
|
@@ -53,52 +51,17 @@ def bench! |
53 | 51 |
|
54 | 52 | private |
55 | 53 |
|
56 | | - def results_cache_key(rev_hash) |
57 | | - key_parts = [rev_hash, @options[:bench_args], @options[:name_filters]].inspect |
58 | | - Digest::MD5.hexdigest(key_parts) |
59 | | - end |
60 | | - |
61 | | - def run_rev(ruby_bench_path, name, rev_hash) |
62 | | - cache_file = File.join(RESULTS_CACHE_DIR, "#{results_cache_key(rev_hash)}.json") |
63 | | - |
64 | | - if File.exist?(cache_file) && !@options[:force_rerun] |
65 | | - LOG.info("Using cached results for #{name} from #{cache_file}") |
66 | | - return JSON.parse(File.read(cache_file)) |
67 | | - end |
68 | | - |
69 | | - out_name = File.join('data', "zjit_diff_#{name}") |
| 54 | + def run_benchmarks(ruby_bench_path) |
70 | 55 | Dir.chdir(ruby_bench_path) do |
71 | 56 | @runner.cmd({ 'RUBIES_DIR' => RUBIES_DIR }, |
72 | 57 | './run_benchmarks.rb', |
73 | 58 | '--chruby', |
74 | | - "#{name}::#{rev_hash} --zjit-stats", |
| 59 | + "before::#{@before_hash} --zjit-stats;after::#{@after_hash} --zjit-stats", |
75 | 60 | '--out-name', |
76 | | - out_name, |
| 61 | + DATA_FILENAME, |
77 | 62 | *@options[:bench_args], |
78 | 63 | *@options[:name_filters]) |
79 | | - end |
80 | | - |
81 | | - result = JSON.parse(File.read(File.join(ruby_bench_path, "#{out_name}.json"))) |
82 | | - FileUtils.mkdir_p(RESULTS_CACHE_DIR) |
83 | | - File.write(cache_file, JSON.generate(result)) |
84 | | - LOG.info("Cached results for #{name} to #{cache_file}") |
85 | | - result |
86 | | - end |
87 | | - |
88 | | - def run_benchmarks(ruby_bench_path) |
89 | | - before_data = run_rev(ruby_bench_path, 'before', @before_hash) |
90 | | - after_data = run_rev(ruby_bench_path, 'after', @after_hash) |
91 | | - |
92 | | - merged = { |
93 | | - 'metadata' => before_data['metadata'].merge(after_data['metadata']), |
94 | | - 'raw_data' => before_data['raw_data'].merge(after_data['raw_data']), |
95 | | - } |
96 | 64 |
|
97 | | - merged_path = File.join(ruby_bench_path, "#{DATA_FILENAME}.json") |
98 | | - FileUtils.mkdir_p(File.dirname(merged_path)) |
99 | | - File.write(merged_path, JSON.generate(merged)) |
100 | | - |
101 | | - Dir.chdir(ruby_bench_path) do |
102 | 65 | @runner.cmd('./misc/zjit_diff.rb', "#{DATA_FILENAME}.json", out: $stdout) |
103 | 66 | end |
104 | 67 | end |
@@ -135,7 +98,7 @@ def initialize(name:, ref:, runner:, force_rebuild: false) |
135 | 98 |
|
136 | 99 | def build! |
137 | 100 | Dir.chdir(@path) do |
138 | | - configure_cmd_args = ['--enable-zjit=stats', '--disable-install-doc'] |
| 101 | + configure_cmd_args = ['--enable-zjit=dev', '--disable-install-doc'] |
139 | 102 | if macos? |
140 | 103 | brew_prefixes = BREW_REQUIRED_PACKAGES.map do |pkg| |
141 | 104 | `brew --prefix #{pkg}`.strip |
@@ -194,7 +157,7 @@ def clean! |
194 | 157 | end |
195 | 158 |
|
196 | 159 | if Dir.exist?(RUBIES_DIR) |
197 | | - LOG.info("Removing ruby installations and cached results from #{RUBIES_DIR}") |
| 160 | + LOG.info("Removing ruby installations from #{RUBIES_DIR}") |
198 | 161 | FileUtils.rm_rf(RUBIES_DIR) |
199 | 162 | end |
200 | 163 |
|
@@ -268,10 +231,6 @@ def parse_ref(ref) |
268 | 231 | options[:force_rebuild] = true |
269 | 232 | end |
270 | 233 |
|
271 | | - opts.on('--force-rerun', 'Force re-running benchmarks even if cached results exist') do |
272 | | - options[:force_rerun] = true |
273 | | - end |
274 | | - |
275 | 234 | opts.on('--quiet', 'Silence output of commands except for benchmark result') do |
276 | 235 | options[:quiet] = true |
277 | 236 | end |
|
0 commit comments