Skip to content

Commit

Permalink
update benchmarks and README
Browse files Browse the repository at this point in the history
  • Loading branch information
bieli committed Mar 2, 2024
1 parent 2f523c7 commit 732c0d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
| --- | --- | --- |
Expand Down Expand Up @@ -144,7 +145,6 @@ iotext_data_row: IoTextDataRow {
}
```


### Example cargo bench outputs
```bash

Expand Down Expand Up @@ -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


```

17 changes: 10 additions & 7 deletions benches/my_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -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))
});
Expand All @@ -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))
});
Expand Down

0 comments on commit 732c0d8

Please sign in to comment.