aboutsummaryrefslogtreecommitdiff
path: root/benches/rendering.rs
diff options
context:
space:
mode:
Diffstat (limited to 'benches/rendering.rs')
-rw-r--r--benches/rendering.rs43
1 files changed, 36 insertions, 7 deletions
diff --git a/benches/rendering.rs b/benches/rendering.rs
index 51e1b13..7fe7877 100644
--- a/benches/rendering.rs
+++ b/benches/rendering.rs
@@ -1,22 +1,51 @@
-use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use criterion::{Criterion, black_box, criterion_group, criterion_main};
use std::fs;
-use wmap_renderer::{render_to_surface, Configuration, StageType};
+use wmap_renderer::{Configuration, StageType, render_to_surface};
fn benchmark_rendering(c: &mut Criterion) {
- let config = Configuration::default();
+ let configuration = Configuration::default();
- let example_source = fs::read_to_string("benches/example.wmap").expect("Failed to read benches/example.wmap");
+ let mut configuration_no_smart = Configuration::default();
+ configuration_no_smart.options.smart_label_positioning = false;
+
+ let example_source =
+ fs::read_to_string("benches/example.wmap").expect("Failed to read benches/example.wmap");
let example_map = wmap_parser::parse(&example_source);
c.bench_function("render example map", |b| {
- b.iter(|| render_to_surface(black_box(&example_map), StageType::default(), &config))
+ b.iter(|| {
+ render_to_surface(
+ black_box(&example_map),
+ StageType::default(),
+ &configuration,
+ )
+ })
+ });
+ c.bench_function("render example map (no smart labels))", |b| {
+ b.iter(|| {
+ render_to_surface(
+ black_box(&example_map),
+ StageType::default(),
+ &configuration_no_smart,
+ )
+ })
});
- let huge_source = fs::read_to_string("benches/huge.wmap").expect("Failed to read benches/huge.wmap");
+ let huge_source =
+ fs::read_to_string("benches/huge.wmap").expect("Failed to read benches/huge.wmap");
let huge_map = wmap_parser::parse(&huge_source);
c.bench_function("render huge map", |b| {
- b.iter(|| render_to_surface(black_box(&huge_map), StageType::default(), &config))
+ b.iter(|| render_to_surface(black_box(&huge_map), StageType::default(), &configuration))
+ });
+ c.bench_function("render huge map", |b| {
+ b.iter(|| {
+ render_to_surface(
+ black_box(&huge_map),
+ StageType::default(),
+ &configuration_no_smart,
+ )
+ })
});
}