Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81317 - trunk/libs/lockfree/test
From: tim_at_[hidden]
Date: 2012-11-13 05:59:28


Author: timblechmann
Date: 2012-11-13 05:59:27 EST (Tue, 13 Nov 2012)
New Revision: 81317
URL: http://svn.boost.org/trac/boost/changeset/81317

Log:
lockfree: cleanups in testsuite
Text files modified:
   trunk/libs/lockfree/test/spsc_queue_test.cpp | 39 ++++++++++++++++-----------------------
   trunk/libs/lockfree/test/test_common.hpp | 2 +-
   trunk/libs/lockfree/test/test_helpers.hpp | 4 ++--
   3 files changed, 19 insertions(+), 26 deletions(-)

Modified: trunk/libs/lockfree/test/spsc_queue_test.cpp
==============================================================================
--- trunk/libs/lockfree/test/spsc_queue_test.cpp (original)
+++ trunk/libs/lockfree/test/spsc_queue_test.cpp 2012-11-13 05:59:27 EST (Tue, 13 Nov 2012)
@@ -15,19 +15,16 @@
 #include <boost/test/unit_test.hpp>
 #endif
 
-
-
 #include <iostream>
 #include <memory>
 
-
 #include "test_helpers.hpp"
+#include "test_common.hpp"
 
 using namespace boost;
 using namespace boost::lockfree;
 using namespace std;
 
-
 BOOST_AUTO_TEST_CASE( simple_spsc_queue_test )
 {
     spsc_queue<int, capacity<64> > f;
@@ -248,7 +245,11 @@
 }
 
 
+#ifndef BOOST_LOCKFREE_STRESS_TEST
 static const boost::uint32_t nodes_per_thread = 100000;
+#else
+static const boost::uint32_t nodes_per_thread = 100000000;
+#endif
 
 struct spsc_queue_tester
 {
@@ -264,10 +265,9 @@
 
     void add(void)
     {
- for (boost::uint32_t i = 0; i != nodes_per_thread; ++i)
- {
- int id = generate_id<int>();
+ for (boost::uint32_t i = 0; i != nodes_per_thread; ++i) {
 
+ int id = generate_id<int>();
             working_set.insert(id);
 
             while (sf.push(id) == false)
@@ -283,15 +283,13 @@
 
         bool success = sf.pop(data);
 
- if (success)
- {
+ if (success) {
             ++received_nodes;
             --spsc_queue_cnt;
             bool erased = working_set.erase(data);
             assert(erased);
             return true;
- }
- else
+ } else
             return false;
     }
 
@@ -299,8 +297,7 @@
 
     void get(void)
     {
- for(;;)
- {
+ for(;;) {
             bool success = get_element();
             if (!running && !success)
                 return;
@@ -332,8 +329,8 @@
 
 BOOST_AUTO_TEST_CASE( spsc_queue_test_caching )
 {
-// spsc_queue_tester test1;
- //test1.run();
+ spsc_queue_tester test1;
+ test1.run();
 }
 
 struct spsc_queue_tester_buffering
@@ -354,10 +351,8 @@
     void add(void)
     {
         boost::array<int, buf_size> input_buffer;
- for (boost::uint32_t i = 0; i != nodes_per_thread; i+=buf_size)
- {
- for (size_t i = 0; i != buf_size; ++i)
- {
+ for (boost::uint32_t i = 0; i != nodes_per_thread; i+=buf_size) {
+ for (size_t i = 0; i != buf_size; ++i) {
                 int id = generate_id<int>();
                 working_set.insert(id);
                 input_buffer[i] = id;
@@ -365,12 +360,10 @@
 
             size_t pushed = 0;
 
- do
- {
+ do {
                 pushed += sf.push(input_buffer.c_array() + pushed,
                                   input_buffer.size() - pushed);
- }
- while (pushed != buf_size);
+ } while (pushed != buf_size);
 
             spsc_queue_cnt+=buf_size;
         }

Modified: trunk/libs/lockfree/test/test_common.hpp
==============================================================================
--- trunk/libs/lockfree/test/test_common.hpp (original)
+++ trunk/libs/lockfree/test/test_common.hpp 2012-11-13 05:59:27 EST (Tue, 13 Nov 2012)
@@ -26,7 +26,7 @@
 #ifndef BOOST_LOCKFREE_STRESS_TEST
     static const long node_count = 5000;
 #else
- static const long node_count = 50000;
+ static const long node_count = 500000;
 #endif
     const int reader_threads;
     const int writer_threads;

Modified: trunk/libs/lockfree/test/test_helpers.hpp
==============================================================================
--- trunk/libs/lockfree/test/test_helpers.hpp (original)
+++ trunk/libs/lockfree/test/test_helpers.hpp 2012-11-13 05:59:27 EST (Tue, 13 Nov 2012)
@@ -28,8 +28,8 @@
 public:
     int calc_index(int_type id)
     {
- // knuth hash ... does not need to be good, but has to be portable
- size_t factor = size_t((float)buckets * 1.616f);
+ // knuth hash ... does not need to be good, but has to be portable
+ size_t factor = size_t((float)buckets * 1.616f);
 
         return ((size_t)id * factor) % buckets;
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk