Skip to content

Commit 7a7d800

Browse files
committed
Make benchmarks/optcarrot/benchmark.rb compatible with the Ractor harness
* Without needing a copy of the benchmark files.
1 parent ccdb04c commit 7a7d800

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ nqueens:
8585
ractor: true
8686
optcarrot:
8787
desc: optcarrot is a functional headless NES emulator, run on a specific game cartridge for a specific number of frames.
88+
ractor: true
8889
protoboeuf:
8990
desc: protoboeuf (pure-Ruby protobuf) message decoding
9091
ractor: true

benchmarks/optcarrot/benchmark.rb

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
11
require_relative '../../harness/loader'
22
require_relative "lib/optcarrot"
33

4-
rom_path = File.join(__dir__, "examples/Lan_Master.nes")
5-
nes = Optcarrot::NES.new(["--headless", rom_path])
6-
nes.reset
4+
if ENV["YJIT_BENCH_RACTOR_HARNESS"]
5+
# Based on bin/optcarrot-bench-parallel-on-ractor
6+
[
7+
Optcarrot::Config::DEFAULT_OPTIONS,
8+
Optcarrot::Config::OPTIONS,
9+
Optcarrot::Driver::DRIVER_DB,
10+
Optcarrot::Audio::PACK_FORMAT,
11+
Optcarrot::APU::Pulse::WAVE_FORM,
12+
Optcarrot::APU::Triangle::WAVE_FORM,
13+
Optcarrot::APU::FRAME_CLOCKS,
14+
Optcarrot::APU::OSCILLATOR_CLOCKS,
15+
Optcarrot::APU::LengthCounter::LUT,
16+
Optcarrot::APU::Noise::LUT,
17+
Optcarrot::APU::Noise::NEXT_BITS_1,
18+
Optcarrot::APU::Noise::NEXT_BITS_6,
19+
Optcarrot::APU::DMC::LUT,
20+
Optcarrot::PPU::DUMMY_FRAME,
21+
Optcarrot::PPU::BOOT_FRAME,
22+
Optcarrot::PPU::SP_PIXEL_POSITIONS,
23+
Optcarrot::PPU::TILE_LUT,
24+
Optcarrot::PPU::NMT_TABLE,
25+
Optcarrot::CPU::DISPATCH,
26+
Optcarrot::ROM::MAPPER_DB,
27+
].each { |const| Ractor.make_shareable(const) }
728

8-
run_benchmark(10) do
9-
200.times { nes.step }
29+
ROM_PATH = File.join(__dir__, "examples/Lan_Master.nes").freeze
30+
ENV["WARMUP_ITRS"] = "1"
31+
32+
run_benchmark(10) do
33+
nes = Optcarrot::NES.new(["-b", "--no-print-video-checksum", ROM_PATH])
34+
nes.reset
35+
36+
200.times { nes.step }
37+
end
38+
else
39+
rom_path = File.join(__dir__, "examples/Lan_Master.nes")
40+
nes = Optcarrot::NES.new(["--headless", rom_path])
41+
nes.reset
42+
43+
run_benchmark(10) do
44+
200.times { nes.step }
45+
end
1046
end

0 commit comments

Comments
 (0)