1
0
dust/dust-lang/benches/addictive_addition.rs

30 lines
662 B
Rust
Raw Normal View History

2024-12-11 06:22:40 +00:00
use std::time::Duration;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dust_lang::run;
const SOURCE: &str = r"
2024-12-11 06:22:40 +00:00
let mut i = 0
while i < 5_000_000 {
i += 1
}
";
fn addictive_addition(source: &str) {
let _ = run(source).unwrap();
}
fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("addictive_addition");
group.measurement_time(Duration::from_secs(15));
group.bench_function("addictive_addition", |b| {
b.iter(|| addictive_addition(black_box(SOURCE)))
});
group.finish();
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);