Leapfrog uses more frequent GC
authorPeizhao Ou <peizhaoo@uci.edu>
Thu, 1 Feb 2018 21:29:55 +0000 (13:29 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Thu, 1 Feb 2018 21:29:55 +0000 (13:29 -0800)
test/junction_driver.cpp

index 62b9d62..1609297 100644 (file)
@@ -13,6 +13,7 @@ const unsigned s_nInsertPercentage = 10;
 const char* kTestName = "InsDelFind";
 // Run GC after "kGCFrequency" operations.
 const size_t kGCFrequency = 3000;
+const size_t kLeapfrogGCFrequency = 1500;
 
 const size_t kCrudeMapSize = 10000;
 const size_t kCrudePassCount = 40000;
@@ -38,7 +39,8 @@ typedef junction::ConcurrentMap_Leapfrog<size_t, size_t> LeapfrogMap;
 typedef junction::ConcurrentMap_Crude<size_t, size_t> CrudeMap;
 
 template <typename Map>
-void run_crude_map(size_t map_size, size_t pass_count, const char* bench_name) {
+void run_crude_map(size_t map_size, size_t pass_count, const char* bench_name,
+    size_t gc_frequency) {
     std::cout << "[ RUN      ] " << kTestName << "." << bench_name << "\n";
     auto start_time = std::chrono::system_clock::now();
 
@@ -73,7 +75,7 @@ void run_crude_map(size_t map_size, size_t pass_count, const char* bench_name) {
 //                    std::cout << "Erased" << i << "\n";
                 }
             }
-            if (++nOperations > kGCFrequency) {
+            if (++nOperations > gc_frequency) {
               junction::DefaultQSBR.update(qsbrContext);
               nOperations = 0;
             }
@@ -97,7 +99,8 @@ void run_crude_map(size_t map_size, size_t pass_count, const char* bench_name) {
 }
 
 template <typename Map>
-void run_test(size_t map_size, size_t pass_count, const char* bench_name) {
+void run_test(size_t map_size, size_t pass_count, const char* bench_name,
+    size_t gc_frequency) {
     std::cout << "[ RUN      ] " << kTestName << "." << bench_name << "\n";
     auto start_time = std::chrono::system_clock::now();
 
@@ -135,7 +138,7 @@ void run_test(size_t map_size, size_t pass_count, const char* bench_name) {
 //                    std::cout << "Erased" << i << "\n";
                 }
             }
-            if (++nOperations > kGCFrequency) {
+            if (++nOperations > gc_frequency) {
                 junction::DefaultQSBR.update(qsbrContext);
                 nOperations = 0;
             }
@@ -158,9 +161,13 @@ void run_test(size_t map_size, size_t pass_count, const char* bench_name) {
 }
 
 int main() {
-    run_test<LinearMap>(kLinearMapSize, kLinearPassCount, kLinearBenchmarkName);
-    run_test<LeapfrogMap>(kLeapfrogMapSize, kLeapfrogPassCount, kLeapfrogBenchmarkName);
-    run_test<GrampaMap>(kGrampaMapSize, kGrampaPassCount, kGrampaBenchmarkName);
-    run_crude_map<CrudeMap>(kCrudeMapSize, kCrudePassCount, kCrudeBenchmarkName);
+    run_test<LeapfrogMap>(kLeapfrogMapSize, kLeapfrogPassCount,
+        kLeapfrogBenchmarkName, kLeapfrogGCFrequency );
+    run_test<LinearMap>(kLinearMapSize, kLinearPassCount, kLinearBenchmarkName,
+        kGCFrequency);
+    run_test<GrampaMap>(kGrampaMapSize, kGrampaPassCount, kGrampaBenchmarkName,
+        kGCFrequency);
+    run_crude_map<CrudeMap>(kCrudeMapSize, kCrudePassCount, kCrudeBenchmarkName,
+        kGCFrequency);
     return 0;
 }