Skip to content

Commit

Permalink
tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Apr 12, 2024
1 parent 97503ac commit 95abc13
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 91 deletions.
65 changes: 50 additions & 15 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fn bench(c: &mut Criterion) {
let mut earcut = Earcut::new();
let mut triangles = Vec::new();

c.bench_function("water", |b| {
let (data, hole_indices) = load_fixture("water");
c.bench_function("bad-hole", |b| {
let (data, hole_indices) = load_fixture("bad-hole");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
})
Expand All @@ -49,6 +49,34 @@ fn bench(c: &mut Criterion) {
})
});

c.bench_function("degenerate", |b| {
let (data, hole_indices) = load_fixture("degenerate");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
})
});

c.bench_function("dude", |b| {
let (data, hole_indices) = load_fixture("dude");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
})
});

c.bench_function("empty-square", |b| {
let (data, hole_indices) = load_fixture("empty-square");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
})
});

c.bench_function("water", |b| {
let (data, hole_indices) = load_fixture("water");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
})
});

c.bench_function("water2", |b| {
let (data, hole_indices) = load_fixture("water2");
b.iter(|| {
Expand All @@ -70,34 +98,41 @@ fn bench(c: &mut Criterion) {
})
});

c.bench_function("water-huge", |b| {
let (data, hole_indices) = load_fixture("water-huge");
c.bench_function("water4", |b| {
let (data, hole_indices) = load_fixture("water4");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
assert_eq!(triangles.len(), 5177 * 3)
})
});

c.bench_function("water-huge2", |b| {
let (data, hole_indices) = load_fixture("water-huge2");
c.bench_function("water-huge", |b| {
let (data, hole_indices) = load_fixture("water-huge");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
assert_eq!(triangles.len(), 5177 * 3)
})
});

c.bench_function("rain", |b| {
let (data, hole_indices) = load_fixture("rain");
c.bench_function("water-huge2", |b| {
let (data, hole_indices) = load_fixture("water-huge2");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
})
});

c.bench_function("hilbert", |b| {
let (data, hole_indices) = load_fixture("hilbert");
b.iter(|| {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
})
});
// c.bench_function("rain", |b| {
// let (data, hole_indices) = load_fixture("rain");
// b.iter(|| {
// earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
// })
// });

// c.bench_function("hilbert", |b| {
// let (data, hole_indices) = load_fixture("hilbert");
// b.iter(|| {
// earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);
// })
// });
}

criterion_group!(benches, bench);
Expand Down
Loading

0 comments on commit 95abc13

Please sign in to comment.