Added different bit_reversal algo to SplitListSet/Map stress test
[libcds.git] / test / stress / framework / stress_test.cpp
index b9e4d7d4d18afb8df32ce6365c0ac64e7ddced1a..e227e22ec414bc3232f4e188e52dd64541ca7abd 100644 (file)
@@ -1,41 +1,58 @@
-/*
-    This file is a part of libcds - Concurrent Data Structures library
-
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
-
-    Source code repo: http://github.com/khizmax/libcds/
-    Download: http://sourceforge.net/projects/libcds/files/
-
-    Redistribution and use in source and binary forms, with or without
-    modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice, this
-    list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
-    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <fstream>
-#include <iostream>
-#include <cds_test/stress_test.h>
+/*\r
+    This file is a part of libcds - Concurrent Data Structures library\r
+\r
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017\r
+\r
+    Source code repo: http://github.com/khizmax/libcds/\r
+    Download: http://sourceforge.net/projects/libcds/files/\r
+\r
+    Redistribution and use in source and binary forms, with or without\r
+    modification, are permitted provided that the following conditions are met:\r
+\r
+    * Redistributions of source code must retain the above copyright notice, this\r
+    list of conditions and the following disclaimer.\r
+\r
+    * Redistributions in binary form must reproduce the above copyright notice,\r
+    this list of conditions and the following disclaimer in the documentation\r
+    and/or other materials provided with the distribution.\r
+\r
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+*/\r
+\r
+#include <fstream>\r
+#include <iostream>\r
+#include <cds_test/stress_test.h>\r
+\r
+#ifdef CDS_ENABLE_HPSTAT\r
+#   include <cds_test/stat_hp_out.h>\r
+#   include <cds_test/stat_dhp_out.h>\r
+#endif\r
 \r
 namespace cds_test {\r
 \r
-    struct property_stream\r
-    {};\r
+    static std::string s_stat_prefix( "stat" );\r
+\r
+    /*static*/ std::string const& property_stream::stat_prefix()\r
+    {\r
+        return s_stat_prefix;\r
+    }\r
+\r
+    /*static*/ void property_stream::set_stat_prefix( char const* prefix )\r
+    {\r
+        if ( prefix && prefix[0] )\r
+            s_stat_prefix = prefix;\r
+        else\r
+            s_stat_prefix = "stat";\r
+    }\r
 \r
     /*static*/ property_stream& stress_fixture::propout()\r
     {\r
@@ -43,26 +60,43 @@ namespace cds_test {
         return s_prop_stream;\r
     }\r
 \r
+    /*static*/ void stress_fixture::print_hp_stat()\r
+    {\r
+#ifdef CDS_ENABLE_HPSTAT\r
+        {\r
+            cds::gc::HP::stat st;\r
+            cds::gc::HP::statistics( st );\r
+            propout() << st;\r
+        }\r
+        {\r
+            cds::gc::DHP::stat st;\r
+            cds::gc::DHP::statistics( st );\r
+            propout() << st;\r
+        }\r
+#endif\r
+    }\r
+\r
+\r
     /*static*/ std::vector<std::string> stress_fixture::load_dictionary()\r
     {\r
         std::vector<std::string> arrString;\r
 \r
-        std::ifstream s;
-        char const* filename = "./dictionary.txt";
-        s.open( filename );
-        if ( !s.is_open() ) {
-            std::cerr << "WARNING: Cannot open test file " << filename << std::endl;
-            return arrString;
-        }
+        std::ifstream s;\r
+        char const* filename = "./dictionary.txt";\r
+        s.open( filename );\r
+        if ( !s.is_open()) {\r
+            std::cerr << "WARNING: Cannot open test file " << filename << std::endl;\r
+            return arrString;\r
+        }\r
 \r
         std::string line;\r
         std::getline( s, line );\r
 \r
         arrString.reserve( std::stoul( line ));\r
 \r
-        while ( !s.eof() ) {\r
+        while ( !s.eof()) {\r
             std::getline( s, line );\r
-            if ( !line.empty() )\r
+            if ( !line.empty())\r
                 arrString.push_back( std::move( line ));\r
         }\r
 \r
@@ -70,5 +104,4 @@ namespace cds_test {
 \r
         return arrString;\r
     }\r
-\r
 } // namespace\r