Skip to content

Commit

Permalink
Switch to Criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
urschrei committed Oct 28, 2019
1 parent 4e858ad commit 65de86a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 41 deletions.
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polylabel"
version = "1.3.1"
version = "1.3.2"
authors = ["Stephan Hügel <urschrei@gmail.com>"]
description = "A Rust implementation of the Polylabel algorithm for finding optimum polygon label positions."
readme = "README.md"
Expand All @@ -18,6 +18,9 @@ num-traits = "0.2.8"
[build-dependencies]
cbindgen = "0.9.0"

[dev-dependencies]
criterion = "0.3.0"

[lib]
name = "polylabel"
crate-type = ["rlib", "cdylib"]
Expand All @@ -28,3 +31,7 @@ doc = true
[profile.release]
rpath = true
lto = true

[[bench]]
name = "benchmark"
harness = false
37 changes: 37 additions & 0 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#[macro_use]
extern crate criterion;
extern crate polylabel;

use criterion::Criterion;
use geo::Polygon;
use polylabel::polylabel;

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("Threaded", |bencher| {
// an L shape
let coords = vec![
(0.0, 0.0),
(4.0, 0.0),
(4.0, 1.0),
(1.0, 1.0),
(1.0, 4.0),
(0.0, 4.0),
(0.0, 0.0),
];
let poly = Polygon::new(coords.into(), vec![]);
bencher.iter(|| {
polylabel(&poly, &10.0);
});
});

c.bench_function("Large Polygon", |bencher| {
let points = include!("../data/norway_main.rs");
let poly = Polygon::new(points.into(), vec![]);
bencher.iter(|| {
polylabel(&poly, &1.0);
});
});
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
34 changes: 0 additions & 34 deletions benches/benchmarks.rs

This file was deleted.

6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ use std::iter::Sum;
mod ffi;
pub use crate::ffi::{polylabel_ffi, Array, Position, WrapperArray};

#[doc(hidden)]
#[allow(dead_code)]
pub extern "C" fn spare() {
println!();
}

/// Represention of a Quadtree node's cells. A node contains four Qcells.
#[derive(Debug)]
struct Qcell<T>
Expand Down

0 comments on commit 65de86a

Please sign in to comment.