From d864c23d9d8ffa703bdbba73071b1aaad6b6e003 Mon Sep 17 00:00:00 2001 From: ringsaturn Date: Mon, 11 Nov 2024 19:49:26 +0800 Subject: [PATCH] Update benchmark runs on Apple M3 Max --- README.md | 30 +- assets/MAD.svg | 394 +++++++++++++++----- assets/SD.svg | 376 +++++++++++++++---- assets/mean.svg | 384 +++++++++++++++----- assets/median.svg | 375 ++++++++++++++----- assets/pdf.svg | 460 ++++++++++++++++-------- assets/pdf_small.svg | 262 +++++++++++--- assets/regression.svg | 696 +++++++++++++++++++++++++----------- assets/regression_small.svg | 659 ++++++++++++++++++++++++---------- assets/slope.svg | 402 +++++++++++++++++---- assets/typical.svg | 402 +++++++++++++++++---- 11 files changed, 3342 insertions(+), 1098 deletions(-) diff --git a/README.md b/README.md index 9a5027d..1445dda 100644 --- a/README.md +++ b/README.md @@ -75,14 +75,36 @@ That's all. There are no black magic tricks inside the tzf-rs. Below is a benchmark run on global cities(about 14K), and avg time is about 3,000 ns per query: -```txt -test benches_default::bench_default_finder_random_city ... bench: 2,870 ns/iter (+/- 182) +```rust +# require toolchain.channel=nightly + +#![feature(test)] +#[cfg(test)] +mod benches_default { + + use tzf_rs::DefaultFinder; + extern crate test; + use test::Bencher; + #[bench] + fn bench_default_finder_random_city(b: &mut Bencher) { + let finder: DefaultFinder = DefaultFinder::default(); + + b.iter(|| { + let city = cities_json::get_random_cities(); + let _ = finder.get_tz_name(city.lng, city.lat); + }); + } +} +``` + +```console +test benches_default::bench_default_finder_random_city ... bench: 1,220.19 ns/iter (+/- 54.36) ``` | Criterion result | Pic | | ---------------- | ----------------------------------------------------------------------------------------- | -| PDF | ![](https://raw.githubusercontent.com/ringsaturn/tzf-rs/main/assets/pdf_small.svg) | -| Regression | ![](https://raw.githubusercontent.com/ringsaturn/tzf-rs/main/assets/regression_small.svg) | +| PDF | ![](https://raw.githubusercontent.com/ringsaturn/tzf-rs/main/assets/pdf.svg) | +| Regression | ![](https://raw.githubusercontent.com/ringsaturn/tzf-rs/main/assets/regression.svg) | You can view more details from latest benchmark from [GitHub Actions logs](https://github.com/ringsaturn/tzf-rs/actions/workflows/rust.yml). diff --git a/assets/MAD.svg b/assets/MAD.svg index 1f14cc4..8da0aa1 100644 --- a/assets/MAD.svg +++ b/assets/MAD.svg @@ -1,88 +1,308 @@ - - -Finders/Default/0:MAD - - -Density (a.u.) - - -Average time (ns) - - - -0.002 - - - -0.004 - - - -0.006 - - - -0.008 - - - -0.01 - - - -0.012 - - - -0.014 - - - - -160 - - - -180 - - - -200 - - - -220 - - - -240 - - - -260 - - - -280 - - - -300 - - - - - - -Bootstrap distribution - - -Confidence interval - - -Point estimate - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 0.02 + + + + + 0.04 + + + + + 0.06 + + + + + 0.08 + + + + + 0.1 + + + + + 0.12 + + + + + 0.14 + + + + + 0.16 + + + + + 24 + + + + + 26 + + + + + 28 + + + + + 30 + + + + + 32 + + + + + 34 + + + + + 36 + + + + + 38 + + + + + + + + + Bootstrap distribution + + + + + Bootstrap distribution + + + + + + Confidence interval + + + + + Confidence interval + + + + + + + + + + Point estimate + + + + + Point estimate + + + + + + + + + + + + Density (a.u.) + + + + + Average time (ns) + + + + + + + Finders/Default/0: MAD + + + + + + diff --git a/assets/SD.svg b/assets/SD.svg index 10cb50e..6b87529 100644 --- a/assets/SD.svg +++ b/assets/SD.svg @@ -1,80 +1,298 @@ - - -Finders/Default/0:SD - - -Density (a.u.) - - -Average time (ns) - - - -0.001 - - - -0.002 - - - -0.003 - - - -0.004 - - - -0.005 - - - -0.006 - - - -0.007 - - - - -250 - - - -300 - - - -350 - - - -400 - - - -450 - - - -500 - - - - - - -Bootstrap distribution - - -Confidence interval - - -Point estimate - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 0.02 + + + + + 0.04 + + + + + 0.06 + + + + + 0.08 + + + + + 0.1 + + + + + 0.12 + + + + + 0.14 + + + + + 28 + + + + + 30 + + + + + 32 + + + + + 34 + + + + + 36 + + + + + 38 + + + + + 40 + + + + + + + + + Bootstrap distribution + + + + + Bootstrap distribution + + + + + + Confidence interval + + + + + Confidence interval + + + + + + + + + + Point estimate + + + + + Point estimate + + + + + + + + + + + + Density (a.u.) + + + + + Average time (ns) + + + + + + + Finders/Default/0: SD + + + + + + diff --git a/assets/mean.svg b/assets/mean.svg index de8a4cd..344fbff 100644 --- a/assets/mean.svg +++ b/assets/mean.svg @@ -1,88 +1,298 @@ - - -Finders/Default/0:mean - - -Density (a.u.) - - -Average time (µs) - - - -2 - - - -4 - - - -6 - - - -8 - - - -10 - - - -12 - - - - -2.58 - - - -2.6 - - - -2.62 - - - -2.64 - - - -2.66 - - - -2.68 - - - -2.7 - - - -2.72 - - - -2.74 - - - - - - -Bootstrap distribution - - -Confidence interval - - -Point estimate - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 20 + + + + + 40 + + + + + 60 + + + + + 80 + + + + + 100 + + + + + 120 + + + + + 1.194 + + + + + 1.196 + + + + + 1.198 + + + + + 1.2 + + + + + 1.202 + + + + + 1.204 + + + + + 1.206 + + + + + 1.208 + + + + + + + + + Bootstrap distribution + + + + + Bootstrap distribution + + + + + + Confidence interval + + + + + Confidence interval + + + + + + + + + + Point estimate + + + + + Point estimate + + + + + + + + + + + + Density (a.u.) + + + + + Average time (µs) + + + + + + + Finders/Default/0: mean + + + + + + diff --git a/assets/median.svg b/assets/median.svg index af3a985..ad245ff 100644 --- a/assets/median.svg +++ b/assets/median.svg @@ -1,84 +1,293 @@ - - -Finders/Default/0:median - - -Density (a.u.) - - -Average time (µs) - - - -5 - - - -10 - - - -15 - - - -20 - - - -25 - - - -30 - - - - -2.52 - - - -2.54 - - - -2.56 - - - -2.58 - - - -2.6 - - - -2.62 - - - -2.64 - - - -2.66 - - - - - - -Bootstrap distribution - - -Confidence interval - - -Point estimate - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 20 + + + + + 40 + + + + + 60 + + + + + 80 + + + + + 100 + + + + + 120 + + + + + 140 + + + + + 160 + + + + + 1.185 + + + + + 1.19 + + + + + 1.195 + + + + + 1.2 + + + + + 1.205 + + + + + + + + + Bootstrap distribution + + + + + Bootstrap distribution + + + + + + Confidence interval + + + + + Confidence interval + + + + + + + + + + Point estimate + + + + + Point estimate + + + + + + + + + + + + Density (a.u.) + + + + + Average time (µs) + + + + + + + Finders/Default/0: median + + + + + + diff --git a/assets/pdf.svg b/assets/pdf.svg index 178f665..47ca637 100644 --- a/assets/pdf.svg +++ b/assets/pdf.svg @@ -1,143 +1,319 @@ - - -Finders/Default/0 - - -Iterations (x 10^3) - - -Average Time (µs) - - - -0 - - - -5 - - - -10 - - - -15 - - - -20 - - - -25 - - - -30 - - - - -1.5 - - - -2 - - - -2.5 - - - -3 - - - -3.5 - - - -4 - - - -4.5 - - - -5 - - - -Density (a.u.) - - - -0 - - - -0.2 - - - -0.4 - - - -0.6 - - - -0.8 - - - -1 - - - -1.2 - - - - - - - - - - - - - - - - - - - - - -PDF - - -Mean - - -"Clean" sample - - -Mild outliers - - -Severe outliers - - - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 10 + + + + + 20 + + + + + 30 + + + + + 40 + + + + + 50 + + + + + 60 + + + + + 70 + + + + + 80 + + + + + 1.15 + + + + + 1.2 + + + + + 1.25 + + + + + 1.3 + + + + + 1.35 + + + + + 0 + + + + + 2 + + + + + 4 + + + + + 6 + + + + + 8 + + + + + 10 + + + + + 12 + + + + + 14 + + + + + + + + + PDF + + + PDF + + + + + + + + + + Mean + + + + + Mean + + + + + + "Clean" sample + + + + + "Clean" sample + + + + + + + + + Mild outliers + + + Mild outliers + + + + + + + + + gnuplot_plot_5 + + + + + + gnuplot_plot_6 + + + + gnuplot_plot_7 + + + + gnuplot_plot_8 + + + + + + + + + + Iterations (x 103) + + + + + Density (a.u.) + + + + + Average time (µs) + + + + + + + Finders/Default/0 + + + + + + diff --git a/assets/pdf_small.svg b/assets/pdf_small.svg index 583d4bb..0e20434 100644 --- a/assets/pdf_small.svg +++ b/assets/pdf_small.svg @@ -1,60 +1,204 @@ - - -Density (a.u.) - - -Average Time (µs) - - - -0 - - - -0.2 - - - -0.4 - - - -0.6 - - - -0.8 - - - -1 - - - -1.2 - - - -1.4 - - - - -2 - - - -3 - - - -4 - - - -5 - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 2 + + + + + 4 + + + + + 6 + + + + + 8 + + + + + 10 + + + + + 12 + + + + + 1.15 + + + + + 1.2 + + + + + 1.25 + + + + + 1.3 + + + + + 1.35 + + + + + + + + + PDF + + + + + + + Mean + + + + + + + + + + + + Density (a.u.) + + + + + Average time (µs) + + + + + + + + diff --git a/assets/regression.svg b/assets/regression.svg index 6be6a88..47cb87a 100644 --- a/assets/regression.svg +++ b/assets/regression.svg @@ -1,212 +1,486 @@ - - -Finders/Default/0 - - -Total sample time (ms) - - -Iterations (x 10^3) - - - - - - - - - - - - - - - - - - - - -10.0 - - - -20.0 - - - -30.0 - - - -40.0 - - - -50.0 - - - -60.0 - - - -70.0 - - - -80.0 - - - -90.0 - - - -100.0 - - - -110.0 - - - - -5 - - - -10 - - - -15 - - - -20 - - - -25 - - - -30 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Sample - - -Linear regression - - -Confidence interval - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 10 + + + + + + + + + + + + + 20 + + + + + + + + + + + + + 30 + + + + + + + + + + + + + 40 + + + + + + + + + + + + + 50 + + + + + + + + + + + + + 60 + + + + + + + + + + + + + 70 + + + + + + + + + + + + + 80 + + + + + + + + + + + + + 90 + + + + + + + + + + + + + 100 + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 10 + + + + + + + + + + + + + 20 + + + + + + + + + + + + + 30 + + + + + + + + + + + + + 40 + + + + + + + + + + + + + 50 + + + + + + + + + + + + + 60 + + + + + + + + + + + + + 70 + + + + + + + + + + + + + 80 + + + + + + + + + + + + + 90 + + + + + + + + + Sample + + + Sample + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Linear regression + + + + + Linear regression + + + + + + Confidence interval + + + + + Confidence interval + + + + + + + + + + + + + + + + + + + Total sample time (ms) + + + + + Iterations (x 103) + + + + + + + Finders/Default/0 + + + + + + diff --git a/assets/regression_small.svg b/assets/regression_small.svg index ce33063..ce49944 100644 --- a/assets/regression_small.svg +++ b/assets/regression_small.svg @@ -1,197 +1,464 @@ - - -Total sample time (ms) - - -Iterations (x 10^3) - - - - - - - - - - - - - - - - - - - - -10.0 - - - -20.0 - - - -30.0 - - - -40.0 - - - -50.0 - - - -60.0 - - - -70.0 - - - -80.0 - - - -90.0 - - - -100.0 - - - -110.0 - - - - -5 - - - -10 - - - -15 - - - -20 - - - -25 - - - -30 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 10 + + + + + + + + + + + + + 20 + + + + + + + + + + + + + 30 + + + + + + + + + + + + + 40 + + + + + + + + + + + + + 50 + + + + + + + + + + + + + 60 + + + + + + + + + + + + + 70 + + + + + + + + + + + + + 80 + + + + + + + + + + + + + 90 + + + + + + + + + + + + + 100 + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 10 + + + + + + + + + + + + + 20 + + + + + + + + + + + + + 30 + + + + + + + + + + + + + 40 + + + + + + + + + + + + + 50 + + + + + + + + + + + + + 60 + + + + + + + + + + + + + 70 + + + + + + + + + + + + + 80 + + + + + + + + + + + + + 90 + + + + + + + + + Sample + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Linear regression + + + + + + Confidence interval + + + + + + + + + + + + + + + + + + Total sample time (ms) + + + + + Iterations (x 103) + + + + + + + + diff --git a/assets/slope.svg b/assets/slope.svg index 3d43c24..ff78de4 100644 --- a/assets/slope.svg +++ b/assets/slope.svg @@ -1,76 +1,328 @@ - - -Finders/Default/0:slope - - -Density (a.u.) - - -Average time (µs) - - - -1 - - - -2 - - - -3 - - - -4 - - - -5 - - - -6 - - - -7 - - - - -2.6 - - - -2.65 - - - -2.7 - - - -2.75 - - - -2.8 - - - - - - -Bootstrap distribution - - -Confidence interval - - -Point estimate - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 10 + + + + + 20 + + + + + 30 + + + + + 40 + + + + + 50 + + + + + 60 + + + + + 70 + + + + + 80 + + + + + 90 + + + + + 100 + + + + + 1.192 + + + + + 1.194 + + + + + 1.196 + + + + + 1.198 + + + + + 1.2 + + + + + 1.202 + + + + + 1.204 + + + + + 1.206 + + + + + 1.208 + + + + + 1.21 + + + + + + + + + Bootstrap distribution + + + + + Bootstrap distribution + + + + + + Confidence interval + + + + + Confidence interval + + + + + + + + + + Point estimate + + + + + Point estimate + + + + + + + + + + + + Density (a.u.) + + + + + Average time (µs) + + + + + + + Finders/Default/0: slope + + + + + + diff --git a/assets/typical.svg b/assets/typical.svg index 205c782..373f96d 100644 --- a/assets/typical.svg +++ b/assets/typical.svg @@ -1,76 +1,328 @@ - - -Finders/Default/0:typical - - -Density (a.u.) - - -Average time (µs) - - - -1 - - - -2 - - - -3 - - - -4 - - - -5 - - - -6 - - - -7 - - - - -2.6 - - - -2.65 - - - -2.7 - - - -2.75 - - - -2.8 - - - - - - -Bootstrap distribution - - -Confidence interval - - -Point estimate - - - - + + + +Gnuplot +Produced by GNUPLOT 6.0 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 10 + + + + + 20 + + + + + 30 + + + + + 40 + + + + + 50 + + + + + 60 + + + + + 70 + + + + + 80 + + + + + 90 + + + + + 100 + + + + + 1.192 + + + + + 1.194 + + + + + 1.196 + + + + + 1.198 + + + + + 1.2 + + + + + 1.202 + + + + + 1.204 + + + + + 1.206 + + + + + 1.208 + + + + + 1.21 + + + + + + + + + Bootstrap distribution + + + + + Bootstrap distribution + + + + + + Confidence interval + + + + + Confidence interval + + + + + + + + + + Point estimate + + + + + Point estimate + + + + + + + + + + + + Density (a.u.) + + + + + Average time (µs) + + + + + + + Finders/Default/0: typical + + + + + +