From d177461a7214c7aec3e6478f649a1012050c47e2 Mon Sep 17 00:00:00 2001 From: Ruchir Rastogi Date: Mon, 6 Jan 2020 15:03:21 -0800 Subject: [PATCH] Fix bug in stats_event_benchmark Now, the number of elements in each simulated stats_event is correctly sampled from a uniform distribution. Rerunning the benchmarking tests indicates that truncating the buffer increases the number of cycles require to log an event by only 1.6%. Test: m libstatssocket_benchmark Test: bit libstatssocket_benchmark:* Change-Id: I8d5c1734861038beec8eeb7ce1f84a24bde25a75 --- libstats/socket/benchmark/stats_event_benchmark.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libstats/socket/benchmark/stats_event_benchmark.cpp b/libstats/socket/benchmark/stats_event_benchmark.cpp index b487c4d4b..9488168b5 100644 --- a/libstats/socket/benchmark/stats_event_benchmark.cpp +++ b/libstats/socket/benchmark/stats_event_benchmark.cpp @@ -22,7 +22,8 @@ static struct stats_event* constructStatsEvent() { stats_event_set_atom_id(event, 100); // randomly sample atom size - for (int i = 0; i < rand() % 800; i++) { + int numElements = rand() % 800; + for (int i = 0; i < numElements; i++) { stats_event_write_int32(event, i); }