defragmenter_test: Run for fewer iterations under Valgrind 68/68568/3
authorDave Rigby <daver@couchbase.com>
Wed, 3 Aug 2016 13:06:19 +0000 (13:06 +0000)
committerDave Rigby <daver@couchbase.com>
Wed, 12 Oct 2016 09:33:15 +0000 (09:33 +0000)
Currently when this test is run under Valgrind it takes ~150s to
complete; because we create a large (500,000) number of items to
operate on for the benchmark tests. There's little value in
benchmarking under Valgrind, however it is still useful to run the
tests under Valgrind to validate functional correctness.

Therefore reduce the item count to 10 when run under Valgrind. This
reduces the runtime to <10s

Change-Id: Idda46dff5963c29db6890b0c8841c80b1401c010
Reviewed-on: http://review.couchbase.org/68568
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: buildbot <build@couchbase.com>
CMakeLists.txt
tests/module_tests/defragmenter_test.cc

index 639efc9..660c6ed 100644 (file)
@@ -19,6 +19,7 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_INSTALL_PREFIX}/include
                            ${CMAKE_CURRENT_BINARY_DIR}/src
                            ${SNAPPY_INCLUDE_DIR}
                            ${Platform_SOURCE_DIR}/include
+                           ${Platform_SOURCE_DIR}/external
                            ${Memcached_SOURCE_DIR}
                            ${Memcached_SOURCE_DIR}/include
                            ${Couchstore_SOURCE_DIR}/include
index 1e8666a..d03ff75 100644 (file)
@@ -24,6 +24,7 @@
 #include <iomanip>
 #include <locale>
 #include <platform/cb_malloc.h>
+#include <valgrind/valgrind.h>
 
 
 /**
@@ -152,7 +153,13 @@ std::unique_ptr<VBucket> DefragmenterBenchmarkTest::vbucket;
 
 
 TEST_F(DefragmenterBenchmarkTest, Populate) {
-    size_t populateRate = populateVbucket(*vbucket, 500000);
+    // How many items to create in the VBucket. Use a large number for
+    // normal runs when measuring performance, but a very small number
+    // (enough for functional testing) when running under Valgrind
+    // where there's no sense in measuring performance.
+    const size_t item_count = RUNNING_ON_VALGRIND ? 10
+                                                  : 500000;
+    size_t populateRate = populateVbucket(*vbucket, item_count);
     RecordProperty("items_per_sec", populateRate);
 }