From 732c0d860c5be3da51b093a034b218fb60b6fdea Mon Sep 17 00:00:00 2001 From: Marcin Bielak Date: Sat, 2 Mar 2024 19:53:27 +0100 Subject: [PATCH] update benchmarks and README --- README.md | 4 +--- benches/my_benchmark.rs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6dd1f55..eaa472e 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ fn main() { ## Benchmark synthetics tests - guaranty of linear inc. parsing time depends IoText metrics count +Table with tests results: | IoText message size (bytes) | IoText msg. metrics count | avg. parsing time (µs) | | --- | --- | --- | @@ -144,7 +145,6 @@ iotext_data_row: IoTextDataRow { } ``` - ### Example cargo bench outputs ```bash @@ -222,7 +222,5 @@ test tests::test_extract_metric_value_type_decimal ... ok test tests::test_extract_metric_value_type_text ... ok test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - ``` diff --git a/benches/my_benchmark.rs b/benches/my_benchmark.rs index cbbd941..06b524c 100644 --- a/benches/my_benchmark.rs +++ b/benches/my_benchmark.rs @@ -35,13 +35,16 @@ pub fn criterion_benchmark(c: &mut Criterion) { const MSG_EXAMPLE_10_METRICS_3: &str = "|val_water_003=i:12345678,m|val_water_0023=i:15,m|bulb_state3=b:1,m|connector_state3=b:0,m|temp_03=d:341.14,m|temp_023=d:316.4,m|temp_033=d:20.4,m|pwr3=d:32.231,m|current3=d:4.429,m|current_battery3=d:1.548"; const MSG_EXAMPLE_10_METRICS_4: &str = "|val_water_004=i:12345678,m|val_water_0024=i:15,m|bulb_state4=b:1,m|connector_state4=b:0,m|temp_04=d:341.14,m|temp_024=d:316.4,m|temp_034=d:20.4,m|pwr4=d:32.231,m|current4=d:4.429,m|current_battery4=d:1.548"; - - let msg_example_20_metrics: String = format!("{MSG_EXAMPLE_10_METRICS_FIRST}{MSG_EXAMPLE_10_METRICS_2}"); - - let msg_example_30_metrics: String = format!("{MSG_EXAMPLE_10_METRICS_FIRST}{MSG_EXAMPLE_10_METRICS_2}{MSG_EXAMPLE_10_METRICS_3}"); + + let msg_example_20_metrics: String = + format!("{MSG_EXAMPLE_10_METRICS_FIRST}{MSG_EXAMPLE_10_METRICS_2}"); + + let msg_example_30_metrics: String = format!( + "{MSG_EXAMPLE_10_METRICS_FIRST}{MSG_EXAMPLE_10_METRICS_2}{MSG_EXAMPLE_10_METRICS_3}" + ); let msg_example_40_metrics: String = format!("{MSG_EXAMPLE_10_METRICS_FIRST}{MSG_EXAMPLE_10_METRICS_2}{MSG_EXAMPLE_10_METRICS_3}{MSG_EXAMPLE_10_METRICS_4}"); - + let msg_example_50_metrics: String = format!("{MSG_EXAMPLE_10_METRICS_FIRST}{MSG_EXAMPLE_10_METRICS_2}{MSG_EXAMPLE_10_METRICS_3}{MSG_EXAMPLE_10_METRICS_4}{MSG_EXAMPLE_10_METRICS_4}"); let msg_example_100_metrics: String = format!("{MSG_EXAMPLE_10_METRICS_FIRST}{MSG_EXAMPLE_10_METRICS_2}{MSG_EXAMPLE_10_METRICS_3}{MSG_EXAMPLE_10_METRICS_4}{MSG_EXAMPLE_10_METRICS_4}{MSG_EXAMPLE_10_METRICS_2}{MSG_EXAMPLE_10_METRICS_3}{MSG_EXAMPLE_10_METRICS_4}{MSG_EXAMPLE_10_METRICS_4}{MSG_EXAMPLE_10_METRICS_4}"); @@ -51,7 +54,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("parse_iotext_str - 10 metrics", |b| { b.iter(|| data_obj.parse_iotext_str(&MSG_EXAMPLE_10_METRICS_FIRST)) }); - + c.bench_function("parse_iotext_str - 20 metrics", |b| { b.iter(|| data_obj.parse_iotext_str(&msg_example_20_metrics)) }); @@ -63,7 +66,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("parse_iotext_str - 40 metrics", |b| { b.iter(|| data_obj.parse_iotext_str(&msg_example_40_metrics)) }); - + c.bench_function("parse_iotext_str - 50 metrics", |b| { b.iter(|| data_obj.parse_iotext_str(&msg_example_50_metrics)) });