-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename MartinError, benchmarks, streamline get_tile (#1016)
Use MartinError, MartinResult, FileError and FileResult, and other similar enums.
- Loading branch information
Showing
35 changed files
with
344 additions
and
211 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ lints.workspace = true | |
[package] | ||
name = "martin" | ||
# Once the release is published with the hash, update https://github.com/maplibre/homebrew-martin | ||
version = "0.11.0" | ||
version = "0.11.1" | ||
authors = ["Stepan Kuzmin <[email protected]>", "Yuri Astrakhan <[email protected]>", "MapLibre contributors"] | ||
description = "Blazing fast and lightweight tile server with PostGIS, MBTiles, and PMTiles support" | ||
keywords = ["maps", "tiles", "mbtiles", "pmtiles", "postgis"] | ||
|
@@ -54,6 +54,10 @@ path = "src/bin/martin.rs" | |
name = "martin-cp" | ||
path = "src/bin/martin-cp.rs" | ||
|
||
[[bench]] | ||
name = "bench" | ||
harness = false | ||
|
||
[features] | ||
default = [] | ||
bless-tests = [] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use async_trait::async_trait; | ||
use criterion::async_executor::FuturesExecutor; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use martin::srv::get_tile_response; | ||
use martin::{ | ||
CatalogSourceEntry, MartinResult, Source, TileCoord, TileData, TileSources, UrlQuery, | ||
}; | ||
use martin_tile_utils::{Encoding, Format, TileInfo}; | ||
use tilejson::{tilejson, TileJSON}; | ||
|
||
#[derive(Clone, Debug)] | ||
struct NullSource { | ||
tilejson: TileJSON, | ||
} | ||
|
||
impl NullSource { | ||
fn new() -> Self { | ||
Self { | ||
tilejson: tilejson! { "https://example.com/".to_string() }, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Source for NullSource { | ||
fn get_id(&self) -> &str { | ||
"null" | ||
} | ||
|
||
fn get_tilejson(&self) -> &TileJSON { | ||
&self.tilejson | ||
} | ||
|
||
fn get_tile_info(&self) -> TileInfo { | ||
TileInfo::new(Format::Png, Encoding::Internal) | ||
} | ||
|
||
fn clone_source(&self) -> Box<dyn Source> { | ||
Box::new(self.clone()) | ||
} | ||
|
||
fn support_url_query(&self) -> bool { | ||
false | ||
} | ||
|
||
async fn get_tile( | ||
&self, | ||
_xyz: &TileCoord, | ||
_query: &Option<UrlQuery>, | ||
) -> MartinResult<TileData> { | ||
Ok(Vec::new()) | ||
} | ||
|
||
fn get_catalog_entry(&self) -> CatalogSourceEntry { | ||
CatalogSourceEntry::default() | ||
} | ||
} | ||
|
||
async fn process_tile(sources: &TileSources) { | ||
get_tile_response(sources, TileCoord { z: 0, x: 0, y: 0 }, "null", "", None) | ||
.await | ||
.unwrap(); | ||
} | ||
|
||
fn bench_null_source(c: &mut Criterion) { | ||
let sources = TileSources::new(vec![vec![Box::new(NullSource::new())]]); | ||
c.bench_function("get_table_source_tile", |b| { | ||
b.to_async(FuturesExecutor).iter(|| process_tile(&sources)); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, bench_null_source); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.