[libc-commits] [libc] bcf394c - [libc][benchmark] more precise estimate of throughput

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Thu Dec 1 02:21:23 PST 2022


Author: Guillaume Chatelet
Date: 2022-12-01T10:21:13Z
New Revision: bcf394c4d1257890dc5add64c6844b8fddae18ef

URL: https://github.com/llvm/llvm-project/commit/bcf394c4d1257890dc5add64c6844b8fddae18ef
DIFF: https://github.com/llvm/llvm-project/commit/bcf394c4d1257890dc5add64c6844b8fddae18ef.diff

LOG: [libc][benchmark] more precise estimate of throughput

This patch increases precision by performing the integer divivion after the
multiplication.

Added: 
    

Modified: 
    libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp

Removed: 
    


################################################################################
diff  --git a/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
index 1e7f35b9c3d7c..164708ad1a05a 100644
--- a/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
+++ b/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
@@ -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());


        


More information about the libc-commits mailing list