[llvm-branch-commits] [libc] ab57780 - [libc] Refresh benchmark progress bar when needed.

Guillaume Chatelet via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 13 06:11:10 PST 2021


Author: Guillaume Chatelet
Date: 2021-01-13T14:06:51Z
New Revision: ab577807165c45abfbadc117125ec7275cdcc0cf

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

LOG: [libc] Refresh benchmark progress bar when needed.

Added: 
    

Modified: 
    libc/benchmarks/LibcMemoryBenchmarkMain.cpp

Removed: 
    


################################################################################
diff  --git a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
index 99c5879397d9..770336e3205c 100644
--- a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
+++ b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
@@ -262,17 +262,21 @@ template <typename Benchmark> struct MemfunctionBenchmark : IBenchmark {
     };
   }
 
-  void reportProgress(BenchmarkStatus BS) {
+  void reportProgress() {
+    static size_t LastPercent = -1;
     const size_t TotalSteps = Study.Measurements.capacity();
     const size_t Steps = Study.Measurements.size();
     const size_t Percent = 100 * Steps / TotalSteps;
+    if (Percent == LastPercent)
+      return;
+    LastPercent = Percent;
     size_t I = 0;
     errs() << '[';
     for (; I <= Percent; ++I)
       errs() << '#';
     for (; I <= 100; ++I)
       errs() << '_';
-    errs() << "] " << Percent << "%\r";
+    errs() << "] " << Percent << '%' << '\r';
   }
 
   void runTrials(const BenchmarkOptions &Options,
@@ -283,7 +287,7 @@ template <typename Benchmark> struct MemfunctionBenchmark : IBenchmark {
     for (size_t i = 0; i < NumTrials; ++i) {
       const BenchmarkResult Result = benchmark(Options, B, B.functor());
       Study.Measurements.push_back(Result.BestGuess);
-      reportProgress(Result.TerminationStatus);
+      reportProgress();
     }
   }
 
@@ -330,6 +334,7 @@ void writeStudy(const Study &S) {
                            .concat(Output));
   json::OStream JOS(FOS);
   serializeToJson(S, JOS);
+  FOS << "\n";
 }
 
 void main() {


        


More information about the llvm-branch-commits mailing list