lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 346766a 1/4: Improve speed measurements


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 346766a 1/4: Improve speed measurements
Date: Thu, 17 Jan 2019 20:21:20 -0500 (EST)

branch: master
commit 346766a0caa900d4f50b43f3d0da9a1450d8ba59
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Improve speed measurements
    
    Measuring a thousand repetitions in a loop makes timings more stable.
    See:
      https://lists.nongnu.org/archive/html/lmi/2019-01/msg00010.html
---
 stream_cast_test.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/stream_cast_test.cpp b/stream_cast_test.cpp
index d391ed6..a97bb58 100644
--- a/stream_cast_test.cpp
+++ b/stream_cast_test.cpp
@@ -117,11 +117,11 @@ To cast_4(From from, To = To())
 void assay_speed()
 {
     static double const e {2.718281828459045};
-    auto f0 = [] {stream_cast<std::string>(e);};
-    auto f1 = [] {cast_1     <std::string>(e);};
-    auto f2 = [] {cast_2     <std::string>(e);};
-    auto f3 = [] {cast_3     <std::string>(e);};
-    auto f4 = [] {cast_4     <std::string>(e);};
+    auto f0 = [] {for(int n = 0; n < 1000; ++n) stream_cast<std::string>(e);};
+    auto f1 = [] {for(int n = 0; n < 1000; ++n) cast_1     <std::string>(e);};
+    auto f2 = [] {for(int n = 0; n < 1000; ++n) cast_2     <std::string>(e);};
+    auto f3 = [] {for(int n = 0; n < 1000; ++n) cast_3     <std::string>(e);};
+    auto f4 = [] {for(int n = 0; n < 1000; ++n) cast_4     <std::string>(e);};
     std::cout
         << "\n  Speed tests..."
         << "\n  stream_cast     : " << TimeAnAliquot(f0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]