Skip to content

Commit

Permalink
better bench test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Dec 27, 2023
1 parent 702f8c3 commit e3821b8
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 9 deletions.
155 changes: 150 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pmtiles = { version = "0.5", features = ["http-async", "mmap-async-tokio", "tile
postgis = "0.9"
postgres = { version = "0.19", features = ["with-time-0_3", "with-uuid-1", "with-serde_json-1"] }
postgres-protocol = "0.6"
pprof = { version = "0.13", features = ["flamegraph", "criterion"] }
pretty_assertions = "1"
regex = "1"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls-native-roots"] }
Expand Down
10 changes: 8 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ start-pmtiles-server:
docker-compose up -d fileserver

# Run benchmark tests
bench: start
cargo bench
bench:
cargo bench --bench bench
open target/criterion/report/index.html

# Run benchmark tests showing a flamegraph
flamegraph:
cargo bench --bench bench -- --profile-time=10
/opt/google/chrome/chrome "file://$PWD/target/criterion/get_table_source_tile/profile/flamegraph.svg"

# Start release-compiled Martin server and a test database
bench-server: start
Expand Down
1 change: 1 addition & 0 deletions martin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ criterion.workspace = true
ctor.workspace = true
indoc.workspace = true
insta = { workspace = true, features = ["yaml"] }
pprof.workspace = true
10 changes: 8 additions & 2 deletions martin/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use martin::{
CatalogSourceEntry, MartinResult, Source, TileCoord, TileData, TileSources, UrlQuery,
};
use martin_tile_utils::{Encoding, Format, TileInfo};
use pprof::criterion::{Output, PProfProfiler};
use tilejson::{tilejson, TileJSON};

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -48,7 +49,7 @@ impl Source for NullSource {
_xyz: TileCoord,
_url_query: Option<&UrlQuery>,
) -> MartinResult<TileData> {
Ok(Vec::new())
Ok(b"empty".to_vec())
}

fn get_catalog_entry(&self) -> CatalogSourceEntry {
Expand All @@ -69,5 +70,10 @@ fn bench_null_source(c: &mut Criterion) {
});
}

criterion_group!(benches, bench_null_source);
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(None)));
targets = bench_null_source
}

criterion_main!(benches);

0 comments on commit e3821b8

Please sign in to comment.