[libc][benchmark] more precise estimate of throughput
authorGuillaume Chatelet <gchatelet@google.com>
Thu, 1 Dec 2022 10:19:16 +0000 (10:19 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Thu, 1 Dec 2022 10:21:13 +0000 (10:21 +0000)
This patch increases precision by performing the integer divivion after the
multiplication.

libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp

index 1e7f35b..164708a 100644 (file)
@@ -49,8 +49,8 @@ template <typename SetupType, typename ConfigurationType> struct Runner {
   }
 
   ~Runner() {
-    const size_t AvgBytesPerIteration = Setup.getBatchBytes() / Setup.BatchSize;
-    const size_t TotalBytes = State.iterations() * AvgBytesPerIteration;
+    const size_t TotalBytes =
+        (State.iterations() * Setup.getBatchBytes()) / Setup.BatchSize;
     State.SetBytesProcessed(TotalBytes);
     State.SetItemsProcessed(State.iterations());
     State.SetLabel((Twine(Configuration.Name) + "," + Distribution.Name).str());