lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 52456de 3/6: Demonstrate the speed advantage


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 52456de 3/6: Demonstrate the speed advantage of 'badbit'
Date: Thu, 5 Aug 2021 17:10:00 -0400 (EDT)

branch: master
commit 52456defbbe1c08461e8d6390d44f175a9eba4e9
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Demonstrate the speed advantage of 'badbit'
    
    Depending on platform, setting 'badbit' improves speed by a factor of
    seven to eleven.
---
 null_stream_test.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/null_stream_test.cpp b/null_stream_test.cpp
index 37cbb80..3406f26 100644
--- a/null_stream_test.cpp
+++ b/null_stream_test.cpp
@@ -79,6 +79,18 @@ void mete_kuehl()
         }
 }
 
+// Test writing to null stream with 'badbit' set.
+
+void mete_badbit_kuehl()
+{
+    for(int i = 0; i < 1e4; ++i)
+        {
+        std::ostream os(&null_streambuf());
+        os.setstate(std::ios_base::badbit);
+        emit_text_to_stream(os);
+        }
+}
+
 // Test writing to static null stream.
 
 void mete_kuehl_static()
@@ -155,6 +167,7 @@ void assay_speed()
         << "\n  Speed tests..."
         << "\n  /dev/null        : " << TimeAnAliquot(mete_dev_null)
         << "\n  Kühl             : " << TimeAnAliquot(mete_kuehl)
+        << "\n  Kühl, badbit     : " << TimeAnAliquot(mete_badbit_kuehl)
         << "\n  Kühl, static     : " << TimeAnAliquot(mete_kuehl_static)
         << "\n  unopened fstream : " << TimeAnAliquot(mete_unopened_fstream)
         << "\n  fstream, badbit  : " << TimeAnAliquot(mete_badbit_fstream)



reply via email to

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