[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)
- [lmi-commits] [lmi] master updated (7a6262f -> a102012), Greg Chicares, 2021/08/05
- [lmi-commits] [lmi] master 50c1d57 1/6: Don't write solve trace to statusbar, Greg Chicares, 2021/08/05
- [lmi-commits] [lmi] master 440c67d 2/6: Add a null_stream unit test, Greg Chicares, 2021/08/05
- [lmi-commits] [lmi] master 52456de 3/6: Demonstrate the speed advantage of 'badbit',
Greg Chicares <=
- [lmi-commits] [lmi] master 048b2cc 4/6: Demonstrate a peril, Greg Chicares, 2021/08/05
- [lmi-commits] [lmi] master 4bc0910 5/6: Test std::ostream(nullptr) as well, Greg Chicares, 2021/08/05
- [lmi-commits] [lmi] master a102012 6/6: Generally avoid using null_stream(), Greg Chicares, 2021/08/05