Skip to content

Commit 953c7bc

Browse files
committed
Add a fixed-workload harness for OptCarrot with minimal dependencies
1 parent c2724f0 commit 953c7bc

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

bench/optcarrot/fixed-workload.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# A fixed-workload harness for OptCarrot with minimal dependencies.
2+
# This can be useful to debug or tune performance.
3+
#
4+
# Run with:
5+
# jt build --graal
6+
# jt ruby bench/optcarrot/fixed-workload.rb
7+
8+
require_relative 'lib/optcarrot'
9+
require 'benchmark'
10+
11+
number_of_iterations = 5000
12+
13+
rom = File.expand_path('../examples/Lan_Master.nes', __FILE__)
14+
nes = Optcarrot::NES.new ['--headless', rom]
15+
nes.reset
16+
17+
total = Benchmark.realtime do
18+
number_of_iterations.times do
19+
t = Benchmark.realtime { nes.step }
20+
Truffle::Debug.print 1/t
21+
end
22+
end
23+
24+
Truffle::Debug.print "Total: #{total}"

doc/contributor/benchmarking.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ $ jt benchmark bench/classic/mandelbrot.rb --simple
1717
Output is iterations per second, printed roughly every second (more frequently
1818
for the first few iterations).
1919

20+
## OptCarrot
21+
22+
OptCarrot can be run the same way as the example above (with `bench/optcarrot/optcarrot.rb`),
23+
but also has a fixed-workload harness with minimal dependencies,
24+
which can be useful to debug or tune performance.
25+
26+
Run the fixed-workload harness with minimal dependencies with:
27+
28+
```bash
29+
$ jt ruby bench/optcarrot/fixed-workload.rb
30+
```
31+
2032
# Benchmarking without the GraalVM Compiler
2133

2234
You can turn off the GraalVM Compiler if you want, by not including it in the GraalVM build:

0 commit comments

Comments
 (0)