diff --git a/Cargo.lock b/Cargo.lock index d02a685..d5c8d2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,6 +404,18 @@ dependencies = [ "inout", ] +[[package]] +name = "cities-json" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4720186a8069da0585af9ec1e2f9e815d7d1bbe47dc817b8597e31a609f898f" +dependencies = [ + "lazy_static", + "rand 0.8.5", + "serde", + "serde_json", +] + [[package]] name = "clap" version = "4.3.17" @@ -2266,6 +2278,7 @@ dependencies = [ "chashmap", "chrono", "chrono-tz", + "cities-json", "clap", "config", "geo", diff --git a/rtz-build/Cargo.toml b/rtz-build/Cargo.toml index 79844be..ac996c4 100644 --- a/rtz-build/Cargo.toml +++ b/rtz-build/Cargo.toml @@ -13,10 +13,10 @@ categories = ["command-line-utilities"] [features] default = [] -full = ["tz-ned", "tz-osm", "admin-osm", "self-contained"] +full = ["tz-ned", "tz-osm", "admin-osm", "self-contained", "rtz-core/full"] force-rebuild = [] -self-contained = [] +self-contained = ["rtz-core/self-contained"] tz-ned = [] tz-osm = [] diff --git a/rtz/Cargo.toml b/rtz/Cargo.toml index e9b6b7c..722c943 100644 --- a/rtz/Cargo.toml +++ b/rtz/Cargo.toml @@ -85,6 +85,7 @@ js-sys = { version = "0.3.61", optional = true } [dev-dependencies] pretty_assertions = "1.4.0" +cities-json = "*" [build-dependencies] rtz-build = { path = "../rtz-build", version = "0.2.6"} diff --git a/rtz/src/geo/tz/ned.rs b/rtz/src/geo/tz/ned.rs index 3f01dfe..1b75136 100644 --- a/rtz/src/geo/tz/ned.rs +++ b/rtz/src/geo/tz/ned.rs @@ -224,4 +224,12 @@ mod bench { black_box(NedTimezone::lookup(x, y)); }); } + + #[bench] + fn bench_cities(b: &mut Bencher) { + b.iter(|| { + let city = cities_json::get_random_cities(); + black_box(NedTimezone::lookup(city.lng as f32, city.lat as f32)); + }); + } } diff --git a/rtz/src/geo/tz/osm.rs b/rtz/src/geo/tz/osm.rs index 7da56d0..8e4ebb5 100644 --- a/rtz/src/geo/tz/osm.rs +++ b/rtz/src/geo/tz/osm.rs @@ -230,4 +230,12 @@ mod bench { black_box(OsmTimezone::lookup(x, y)); }); } + + #[bench] + fn bench_cities(b: &mut Bencher) { + b.iter(|| { + let city = cities_json::get_random_cities(); + black_box(OsmTimezone::lookup(city.lng as f32, city.lat as f32)); + }); + } }