-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start playing around with some benchmarking
Trying criterion, not sure if I like it for this use case
- Loading branch information
Showing
17 changed files
with
1,537 additions
and
134 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use rlox::interpret; | ||
use std::fs; | ||
|
||
fn binary_trees(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/binary_trees.lox").unwrap(); | ||
c.bench_function("binary_trees", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn equality(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/equality.lox").unwrap(); | ||
c.bench_function("equality", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn fib(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/fib.lox").unwrap(); | ||
c.bench_function("fib", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn instantiation(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/instantiation.lox").unwrap(); | ||
c.bench_function("instantiation", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn method_call(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/method_call.lox").unwrap(); | ||
c.bench_function("method_call", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn properties(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/properties.lox").unwrap(); | ||
c.bench_function("properties", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn string_equality(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/string_equality.lox").unwrap(); | ||
c.bench_function("string_equality", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn trees(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/trees.lox").unwrap(); | ||
c.bench_function("trees", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
fn zoo(c: &mut Criterion) { | ||
let code = fs::read_to_string("test/benchmark_v2/zoo.lox").unwrap(); | ||
c.bench_function("zoo", |b| b.iter(|| interpret(black_box(&code), false, false))); | ||
} | ||
|
||
criterion_group!(benches, binary_trees, equality, fib, instantiation, method_call, properties, string_equality, trees, zoo); | ||
criterion_main!(benches); |
Oops, something went wrong.