diff options
author | Nikita Putikhin <nputikhin@google.com> | 2023-09-14 16:56:11 +0200 |
---|---|---|
committer | Nikita Putikhin <nputikhin@google.com> | 2023-09-14 17:24:09 +0200 |
commit | e375116b766eff1027273bebc7f5837e829caecc (patch) | |
tree | 9f3e4ea597756b6f40ee262a25259cca2147375e /libatrace_rust | |
parent | bb4703b0ad52b8a32c8591ba79f0a5db5c738427 (diff) | |
download | extras-e375116b766eff1027273bebc7f5837e829caecc.tar.gz |
Move making the vector out of benchmark iter
The difference is within normal noise levels but it's a bit neater.
Bug: 293435349
Test: run benchmark
Change-Id: If46ceaa00a0c57942553e4710a2e8fbc366edefb
Diffstat (limited to 'libatrace_rust')
-rw-r--r-- | libatrace_rust/benchmark/README.md | 20 | ||||
-rw-r--r-- | libatrace_rust/benchmark/src/tracing_subscriber_benchmark.rs | 16 |
2 files changed, 22 insertions, 14 deletions
diff --git a/libatrace_rust/benchmark/README.md b/libatrace_rust/benchmark/README.md index b80d1627..e8532952 100644 --- a/libatrace_rust/benchmark/README.md +++ b/libatrace_rust/benchmark/README.md @@ -48,7 +48,7 @@ device may be different but we expect similar relative performance between Rust *If you notice that measurements with tracing off and tracing on have similar times, it might mean that enabling ATrace events failed and you need to debug the benchmark.* -### ATrace wrapper benchmark results +### ATrace wrapper Rust results from `libatrace_rust_benchmark 2>&1 | grep time`: @@ -75,7 +75,7 @@ BM_TracingOnAtraceBegin/1000 1151 ns 1142 ns 615781 BM_TracingOnAtraceEnd 1076 ns 1069 ns 653646 ``` -### ATrace tracing subscriber benchmark results +### ATrace tracing subscriber The tracing subscriber time consists of the underlying `libatrace_rust` call plus the time spent in the subscriber itself. @@ -83,12 +83,12 @@ the subscriber itself. Results from `libatrace_tracing_subscriber_benchmark 2>&1 | grep time`: ```text -tracing_off_event time: [312.28 ns 314.32 ns 316.71 ns] -tracing_off_event_args time: [2.1963 µs 2.2101 µs 2.2257 µs] -tracing_off_span time: [686.20 ns 707.75 ns 727.21 ns] -tracing_off_span_args time: [2.8813 µs 2.8928 µs 2.9044 µs] -tracing_on_event time: [1.6981 µs 1.7117 µs 1.7264 µs] -tracing_on_event_args time: [3.6242 µs 3.6466 µs 3.6718 µs] -tracing_on_span time: [3.1288 µs 3.1446 µs 3.1612 µs] -tracing_on_span_args time: [5.3117 µs 5.3344 µs 5.3598 µs] +tracing_off_event time: [298.67 ns 299.99 ns 301.52 ns] +tracing_off_event_args time: [2.1225 µs 2.1429 µs 2.1647 µs] +tracing_off_span time: [610.88 ns 619.88 ns 628.70 ns] +tracing_off_span_args time: [2.6585 µs 2.6698 µs 2.6845 µs] +tracing_on_event time: [1.6249 µs 1.6495 µs 1.6887 µs] +tracing_on_event_args time: [3.5608 µs 3.5831 µs 3.6064 µs] +tracing_on_span time: [3.1778 µs 3.1982 µs 3.2211 µs] +tracing_on_span_args time: [5.4340 µs 5.4717 µs 5.5143 µs] ``` diff --git a/libatrace_rust/benchmark/src/tracing_subscriber_benchmark.rs b/libatrace_rust/benchmark/src/tracing_subscriber_benchmark.rs index 07899496..17e9e44a 100644 --- a/libatrace_rust/benchmark/src/tracing_subscriber_benchmark.rs +++ b/libatrace_rust/benchmark/src/tracing_subscriber_benchmark.rs @@ -19,6 +19,10 @@ use atrace_tracing_subscriber::AtraceSubscriber; use criterion::Criterion; use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; +fn make_example_vec() -> Vec<i32> { + Vec::from([1, 2, 3, 4]) +} + fn bench_with_subscriber<F>(c: &mut Criterion, name: &str, mut f: F) where F: FnMut(), @@ -36,10 +40,11 @@ fn bench_tracing_off_event(c: &mut Criterion) { fn bench_tracing_off_event_args(c: &mut Criterion) { turn_tracing_off(); + let v = make_example_vec(); bench_with_subscriber(c, "tracing_off_event_args", || { tracing::info!(debug_arg1 = 123, debug_arg2 = "argument", - debug_arg3 = ?Vec::from([1, 2, 3, 4]), + debug_arg3 = ?v, debug_arg4 = "last", "bench info event") }); @@ -54,10 +59,11 @@ fn bench_tracing_off_span(c: &mut Criterion) { fn bench_tracing_off_span_args(c: &mut Criterion) { turn_tracing_off(); + let v = make_example_vec(); bench_with_subscriber(c, "tracing_off_span_args", || { let _entered = tracing::info_span!("bench info span", debug_arg1 = 123, debug_arg2 = "argument", - debug_arg3 = ?Vec::from([1, 2, 3, 4]), + debug_arg3 = ?v, debug_arg4 = "last") .entered(); }); @@ -71,10 +77,11 @@ fn bench_tracing_on_event(c: &mut Criterion) { fn bench_tracing_on_event_args(c: &mut Criterion) { turn_tracing_on(); + let v = make_example_vec(); bench_with_subscriber(c, "tracing_on_event_args", || { tracing::info!(debug_arg1 = 123, debug_arg2 = "argument", - debug_arg3 = ?Vec::from([1, 2, 3, 4]), + debug_arg3 = ?v, debug_arg4 = "last", "bench info event") }); @@ -91,10 +98,11 @@ fn bench_tracing_on_span(c: &mut Criterion) { fn bench_tracing_on_span_args(c: &mut Criterion) { turn_tracing_on(); + let v = make_example_vec(); bench_with_subscriber(c, "tracing_on_span_args", || { let _entered = tracing::info_span!("bench info span", debug_arg1 = 123, debug_arg2 = "argument", - debug_arg3 = ?Vec::from([1, 2, 3, 4]), + debug_arg3 = ?v, debug_arg4 = "last") .entered(); }); |