Refactors folly test cases to use gtest
authorPeizhao Ou <peizhaoo@uci.edu>
Fri, 9 Feb 2018 08:54:12 +0000 (00:54 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Fri, 9 Feb 2018 08:54:12 +0000 (00:54 -0800)
folly/stress-test/stress-sequential-folly-map.cpp
folly/stress-test/stress-sequential-folly-queue.cpp
folly/stress-test/stress-sequential-folly-sync.cpp

index c9acaee..53b9529 100644 (file)
@@ -2,29 +2,22 @@
 #include <folly/AtomicHashMap.h>
 #include <folly/AtomicUnorderedMap.h>
 
+#include <gtest/gtest.h>
 
-#include <chrono>
-#include <cassert>
-#include <iostream>
 #include <memory>
 
 namespace {
 
 const unsigned s_nInsertPercentage = 10;
-const char* kTestName = "InsDelFind";
 
 const size_t kConcurrentHashMapSize = 10000;
 const size_t kConcurrentHashMapPassCount = 36000;
-const char* kConcurrentHashMapBenchmarkName = "FollyConcurrentHashMap";
 
 const size_t kAtomicHashMapSize = 10000;
 const size_t kAtomicHashMapPassCount = 250000;
-const char* kAtomicHashMapBenchmarkName = "FollyAtomicHashMap";
 
 const size_t kAtomicUnorderedInsertMapSize = 10000;
 const size_t kAtomicUnorderedInsertMapPassCount = 500000;
-const char* kAtomicUnorderedInsertMapBenchmarkName =
-    "FollyAtomicUnorderedInsertMap";
 
 typedef folly::ConcurrentHashMap<size_t, size_t> ConcurrentHashMap;
 typedef folly::AtomicHashMap<size_t, size_t> AtomicHashMap;
@@ -48,11 +41,7 @@ bool map_contains(const Map* map, Key key) {
 }
 
 template <typename Map>
-void run_atomic_unordered_insert_map(size_t map_size, size_t pass_count,
-                                     const char* bench_name) {
-    std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-    auto start_time = std::chrono::system_clock::now();
-
+void run_atomic_unordered_insert_map(size_t map_size, size_t pass_count) {
     size_t nInsertedNum = 0;
     size_t nFindSuccess = 0;
     std::unique_ptr<Map> map(new Map(map_size));
@@ -78,32 +67,15 @@ void run_atomic_unordered_insert_map(size_t map_size, size_t pass_count,
             {
                 if (map_contains(map.get(), i)) {
                     ++nFindSuccess;
-//                    std::cout << "Found" << i << "\n";
                 }
             }
         }
     }
-    auto finish_time = std::chrono::system_clock::now();
-    auto dur = finish_time - start_time;
-    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-
-    if (nFindSuccess != nInsertedNum) {
-        std::cout << "nFindSuccess=" << nFindSuccess << ", nInsertedNum="
-                  << nInsertedNum << std::endl;
-        std::cout << "[       FAILED ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-        assert(false && "ConcurrentMap ERROR");
-    } else {
-        std::cout << "[       OK ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-    }
+    EXPECT_EQ(nFindSuccess, nInsertedNum);
 }
 
 template <typename Map>
-void run_atomic_hashmap(size_t map_size, size_t pass_count, const char* bench_name) {
-    std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-    auto start_time = std::chrono::system_clock::now();
-
+void run_atomic_hashmap(size_t map_size, size_t pass_count) {
     size_t nInsertedNum = 0;
     size_t nFindSuccess = 0;
     std::unique_ptr<Map> map(new Map(map_size));
@@ -129,33 +101,15 @@ void run_atomic_hashmap(size_t map_size, size_t pass_count, const char* bench_na
             {
                 if (map_contains(map.get(), i)) {
                     ++nFindSuccess;
-//                    std::cout << "Found" << i << "\n";
                 }
             }
         }
     }
-    auto finish_time = std::chrono::system_clock::now();
-    auto dur = finish_time - start_time;
-    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-
-    if (nFindSuccess != nInsertedNum) {
-        std::cout << "nFindSuccess=" << nFindSuccess << ", nInsertedNum="
-                  << nInsertedNum << std::endl;
-        std::cout << "[       FAILED ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-        assert(false && "ConcurrentMap ERROR");
-    } else {
-        std::cout << "[       OK ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-    }
+    EXPECT_EQ(nFindSuccess, nInsertedNum);
 }
 
 template <typename Map>
-void run_concurrent_hashmap(size_t map_size, size_t pass_count,
-                            const char* bench_name) {
-    std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-    auto start_time = std::chrono::system_clock::now();
-
+void run_concurrent_hashmap(size_t map_size, size_t pass_count) {
     size_t nInsertedNum = 0;
     size_t nFindSuccess = 0;
     std::unique_ptr<Map> map(new Map(map_size));
@@ -167,53 +121,48 @@ void run_concurrent_hashmap(size_t map_size, size_t pass_count,
             if (i % s_nInsertPercentage == 1) {
                   auto iter = map->insert({i, n});
                   nInsertedNum++;
-//              std::cout << "Inserted" << i << "\n";
             }
             // Find
             {
                 if (map_contains(map.get(), i)) {
                     ++nFindSuccess;
-//                    std::cout << "Found" << i << "\n";
                 }
             }
             // Delete
             if (i % s_nInsertPercentage == 1) {
                 if (map_contains(map.get(), i)) {
                     map->erase(i);
-//                    std::cout << "Erased" << i << "\n";
                 }
             }
         }
     }
-    auto finish_time = std::chrono::system_clock::now();
-    auto dur = finish_time - start_time;
-    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-
-    if (nFindSuccess != nInsertedNum) {
-        std::cout << "nFindSuccess=" << nFindSuccess << ", nInsertedNum="
-                  << nInsertedNum << std::endl;
-        std::cout << "[       FAILED ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-        assert(false && "ConcurrentMap ERROR");
-    } else {
-        std::cout << "[       OK ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-    }
+    EXPECT_EQ(nFindSuccess, nInsertedNum);
 }
 
-int main() {
+class FollyMapInsDelFindTest: public ::testing::Test {
+};
+
+TEST_F(FollyMapInsDelFindTest, FollyConcurrentHashMap) {
   run_concurrent_hashmap<ConcurrentHashMap>(
           kConcurrentHashMapSize,
-          kConcurrentHashMapPassCount,
-          kConcurrentHashMapBenchmarkName);
+          kConcurrentHashMapPassCount);
+}
+
+TEST_F(FollyMapInsDelFindTest, FollyAtomicHashMap) {
   run_atomic_hashmap<AtomicHashMap>(
           kAtomicHashMapSize,
-          kAtomicHashMapPassCount,
-          kAtomicHashMapBenchmarkName);
+          kAtomicHashMapPassCount);
+}
+
+TEST_F(FollyMapInsDelFindTest, FollyAtomicUnorderedInsertMap) {
   run_atomic_unordered_insert_map<AtomicUnorderedInsertMap>(
           kAtomicUnorderedInsertMapSize,
-          kAtomicUnorderedInsertMapPassCount,
-          kAtomicUnorderedInsertMapBenchmarkName);
+          kAtomicUnorderedInsertMapPassCount);
+}
 
-  return 0;
+int main(int argc, char** argv) {
+  // Init Google test
+  ::testing::InitGoogleTest(&argc, argv);
+  int result = RUN_ALL_TESTS();
+  return result;
 }
index d3c3906..70bcb15 100644 (file)
@@ -3,25 +3,18 @@
 #include <folly/AtomicLinkedList.h>
 #include <folly/MPMCQueue.h>
 
-#include <chrono>
-#include <cassert>
-#include <iostream>
+#include <gtest/gtest.h>
+
 #include <memory>
 
 namespace {
 
-const char* kTestName = "EnqueueDequeue";
-
 // Unbounded queue
 size_t kUnboundedQueueEnqueueStride = 10000;
 size_t kUSPSCQueueEnqueueCount = 1200000000;
-const char* kUSPSCQueueBenchmarkName = "FollyUnboundedQueue_SPSC";
 size_t kUMPSCQueueEnqueueCount = 320000000;
-const char* kUMPSCQueueBenchmarkName = "FollyUnboundedQueue_MPSC";
 size_t kUSPMCQueueEnqueueCount = 320000000;
-const char* kUSPMCQueueBenchmarkName = "FollyUnboundedQueue_SPMC";
 size_t kUMPMCQueueEnqueueCount = 320000000;
-const char* kUMPMCQueueBenchmarkName = "FollyUnboundedQueue_MPMC";
 
 typedef folly::USPSCQueue<size_t, false> USPSCQueue;
 typedef folly::UMPSCQueue<size_t, false> UMPSCQueue;
@@ -32,13 +25,9 @@ typedef folly::UMPMCQueue<size_t, false> UMPMCQueue;
 size_t kDynamicBoundedQueueEnqueueStride = 50000;
 size_t kDynamicBoundedQueueCapacity = 200000;
 size_t kDSPSCQueueEnqueueCount = 1200000000;
-const char* kDSPSCQueueBenchmarkName = "FollyDynamicBoundedQueue_SPSC";
 size_t kDMPSCQueueEnqueueCount = 320000000;
-const char* kDMPSCQueueBenchmarkName = "FollyDynamicBoundedQueue_MPSC";
 size_t kDSPMCQueueEnqueueCount = 320000000;
-const char* kDSPMCQueueBenchmarkName = "FollyDynamicBoundedQueue_SPMC";
 size_t kDMPMCQueueEnqueueCount = 320000000;
-const char* kDMPMCQueueBenchmarkName = "FollyDynamicBoundedQueue_MPMC";
 
 typedef folly::DSPSCQueue<size_t, false> DSPSCQueue;
 typedef folly::DMPSCQueue<size_t, false> DMPSCQueue;
@@ -48,22 +37,17 @@ typedef folly::DMPMCQueue<size_t, false> DMPMCQueue;
 // AtomicLinkedList
 size_t kAtomicLinkedListSize = 50000;
 size_t kAtomicLinkedListPassCount = 10000;
-const char* kAtomicLinkedListBenchmarkName = "FollyAtomicLinkedList";
 typedef folly::AtomicLinkedList<size_t> AtomicLinkedList;
 
 // MPMC Queue (linearizable)
 size_t kMPMCQueueEnqueueStride = 10000;
 size_t kMPMCQueueCapacity = 50000;
 size_t kMPMCQueueEnqueueCount = 500000000;
-const char* kMPMCQueueBenchmarkName = "FollyMPMCQueue";
 typedef folly::MPMCQueue<size_t> MPMCQueue;
 
 }
 
 void run_atomic_linkedlist() {
-  std::cout << "[ RUN      ] " << kTestName << "."
-            << kAtomicLinkedListBenchmarkName << std::endl;
-  auto start_time = std::chrono::system_clock::now();
   for (size_t pass = 0; pass < kAtomicLinkedListPassCount; pass++) {
     std::unique_ptr<AtomicLinkedList> list(new AtomicLinkedList());
     bool in_order = true;
@@ -80,30 +64,12 @@ void run_atomic_linkedlist() {
     in_order = !in_order;
 
     size_t supposed_sum = kAtomicLinkedListSize * (kAtomicLinkedListSize - 1) / 2;
-    if (nSum != supposed_sum) {
-      std::cout << "Sequential linked list pop sum: " << nSum
-                << " != " << supposed_sum << "\n";
-      auto finish_time = std::chrono::system_clock::now();
-      auto dur = finish_time - start_time;
-      auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-      std::cout << "[       FAILED ] " << kTestName << "." << kAtomicLinkedListBenchmarkName
-                << " (" << milisecs.count() << " ms)" << std::endl;
-      assert(false && "Folly AtomicLinkedList ERROR");
-    }
+    EXPECT_EQ(nSum, supposed_sum);
   }
-  auto finish_time = std::chrono::system_clock::now();
-  auto dur = finish_time - start_time;
-  auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-  std::cout << "[       OK ] " << kTestName << "." << kAtomicLinkedListBenchmarkName
-            << " (" << milisecs.count() << " ms)" << std::endl;
 }
 
 template <typename Queue>
-void run_queue(Queue* q, size_t enqueue_count, const char* bench_name,
-               size_t enqueue_stride) {
-    std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-    auto start_time = std::chrono::system_clock::now();
-
+void run_queue(Queue* q, size_t enqueue_count, size_t enqueue_stride) {
     size_t nNo = 0;
     size_t pop_sum = 0;
     while (nNo < enqueue_count) {
@@ -118,31 +84,13 @@ void run_queue(Queue* q, size_t enqueue_count, const char* bench_name,
         pop_sum += res;
       }
     }
-
-    auto finish_time = std::chrono::system_clock::now();
-    auto dur = finish_time - start_time;
-    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-
     size_t supposed_sum = enqueue_count * (enqueue_count - 1) / 2;
-    if (pop_sum != supposed_sum) {
-      std::cout << "Sequential queue pop sum: " << pop_sum
-                << " != " << supposed_sum << "\n";
-      std::cout << "[       FAILED ] " << kTestName << "." << bench_name
-                << " (" << milisecs.count() << " ms)" << std::endl;
-      assert(false && "Folly concurrent queue ERROR");
-    } else {
-        std::cout << "[       OK ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-    }
+    EXPECT_EQ (pop_sum, supposed_sum);
 }
 
 // MPMC Specialization.
 template <>
-void run_queue(MPMCQueue* q, size_t enqueue_count, const char* bench_name,
-               size_t enqueue_stride) {
-    std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-    auto start_time = std::chrono::system_clock::now();
-
+void run_queue(MPMCQueue* q, size_t enqueue_count, size_t enqueue_stride) {
     size_t nNo = 0;
     size_t push_sum = 0;
     size_t pop_sum = 0;
@@ -161,86 +109,88 @@ void run_queue(MPMCQueue* q, size_t enqueue_count, const char* bench_name,
       }
     }
 
-    auto finish_time = std::chrono::system_clock::now();
-    auto dur = finish_time - start_time;
-    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-
     size_t supposed_sum = enqueue_count * (enqueue_count - 1) / 2;
-    if (pop_sum != supposed_sum) {
-      std::cout << "Sequential queue pop sum: " << pop_sum
-                << " != " << supposed_sum << "\n";
-      std::cout << "[       FAILED ] " << kTestName << "." << bench_name
-                << " (" << milisecs.count() << " ms)" << std::endl;
-      assert(false && "Folly concurrent queue ERROR");
-    } else {
-        std::cout << "[       OK ] " << kTestName << "." << bench_name
-                  << " (" << milisecs.count() << " ms)" << std::endl;
-    }
+    EXPECT_EQ(pop_sum, supposed_sum);
 }
 
 template <typename Queue>
-void run_without_initial_capacity(size_t enqueue_count, const char* bench_name,
-                                  size_t enqueue_stride) {
+void run_without_initial_capacity(size_t enqueue_count, size_t enqueue_stride) {
   std::unique_ptr<Queue> q(new Queue());
-  run_queue(q.get(), enqueue_count, bench_name, enqueue_stride);
+  run_queue(q.get(), enqueue_count, enqueue_stride);
 }
 
 template <typename Queue>
 void run_with_initial_capacity(size_t queue_capacity, size_t enqueue_count,
-                               const char* bench_name, size_t enqueue_stride) {
+                               size_t enqueue_stride) {
   std::unique_ptr<Queue> q(new Queue(queue_capacity));
-  run_queue(q.get(), enqueue_count, bench_name, enqueue_stride);
+  run_queue(q.get(), enqueue_count, enqueue_stride);
 }
 
-int main() {
-  // MPMCQueue
+class FollyQueueEnqueueDequeueTest : public ::testing::Test {
+
+};
+
+TEST_F(FollyQueueEnqueueDequeueTest, FollyMPMCQueue) {
   run_with_initial_capacity<MPMCQueue>(
-      kMPMCQueueCapacity ,
-      kMPMCQueueEnqueueCount,
-      kMPMCQueueBenchmarkName,
-      kMPMCQueueEnqueueStride);
+      kMPMCQueueCapacity, kMPMCQueueEnqueueCount, kMPMCQueueEnqueueStride);
+}
 
-  // AtomicLinkedList
+TEST_F(FollyQueueEnqueueDequeueTest, FollyAtomicLinkedList) {
   run_atomic_linkedlist();
+}
 
-  // UnboundedQueue
+TEST_F(FollyQueueEnqueueDequeueTest, FollyUnboundedQueue_SPSC) {
   run_without_initial_capacity<USPSCQueue>(
-      kUSPSCQueueEnqueueCount,
-      kUSPSCQueueBenchmarkName,
-      kUnboundedQueueEnqueueStride);
+      kUSPSCQueueEnqueueCount, kUnboundedQueueEnqueueStride);
+}
+
+TEST_F(FollyQueueEnqueueDequeueTest, FollyUnboundedQueue_MPSC) {
   run_without_initial_capacity<UMPSCQueue>(
-      kUMPSCQueueEnqueueCount,
-      kUMPSCQueueBenchmarkName,
-      kUnboundedQueueEnqueueStride);
+      kUMPSCQueueEnqueueCount, kUnboundedQueueEnqueueStride);
+}
+
+TEST_F(FollyQueueEnqueueDequeueTest, FollyUnboundedQueue_SPMC) {
   run_without_initial_capacity<USPMCQueue>(
-      kUSPMCQueueEnqueueCount,
-      kUSPMCQueueBenchmarkName,
-      kUnboundedQueueEnqueueStride);
+      kUSPMCQueueEnqueueCount, kUnboundedQueueEnqueueStride);
+}
+
+TEST_F(FollyQueueEnqueueDequeueTest, FollyUnboundedQueue_MPMC) {
   run_without_initial_capacity<UMPMCQueue>(
       kUMPMCQueueEnqueueCount,
-      kUMPMCQueueBenchmarkName,
       kUnboundedQueueEnqueueStride);
+}
 
+TEST_F(FollyQueueEnqueueDequeueTest, FollyDynamicBoundedQueue_SPSC) {
   // DynamicBoundedQueue
   run_with_initial_capacity<DSPSCQueue>(
-      kDynamicBoundedQueueCapacity ,
-      kDSPSCQueueEnqueueCount, kDSPSCQueueBenchmarkName,
-      kDynamicBoundedQueueEnqueueStride);
+      kDynamicBoundedQueueCapacity,
+      kDSPSCQueueEnqueueCount, kDynamicBoundedQueueEnqueueStride);
+}
+
+TEST_F(FollyQueueEnqueueDequeueTest, FollyDynamicBoundedQueue_MPSC) {
   run_with_initial_capacity<DMPSCQueue>(
       kDynamicBoundedQueueCapacity,
       kDMPSCQueueEnqueueCount,
-      kDMPSCQueueBenchmarkName,
       kDynamicBoundedQueueEnqueueStride);
+}
+
+TEST_F(FollyQueueEnqueueDequeueTest, FollyDynamicBoundedQueue_SPMC) {
   run_with_initial_capacity<DSPMCQueue>(
       kDynamicBoundedQueueCapacity,
       kDSPMCQueueEnqueueCount,
-      kDSPMCQueueBenchmarkName,
       kDynamicBoundedQueueEnqueueStride);
+}
+
+TEST_F(FollyQueueEnqueueDequeueTest, FollyDynamicBoundedQueue_MPMC) {
   run_with_initial_capacity<DMPMCQueue>(
       kDynamicBoundedQueueCapacity,
       kDMPMCQueueEnqueueCount,
-      kDMPMCQueueBenchmarkName,
       kDynamicBoundedQueueEnqueueStride);
+}
 
-  return 0;
+int main(int argc, char** argv) {
+  // Init Google test
+  ::testing::InitGoogleTest(&argc, argv);
+  int result = RUN_ALL_TESTS();
+  return result;
 }
index dbedef0..775252c 100644 (file)
@@ -3,56 +3,41 @@
 #include <folly/SharedMutex.h>
 #include <folly/synchronization/Rcu.h>
 
-#include <chrono>
-#include <cassert>
-#include <iostream>
+#include <gtest/gtest.h>
+
 #include <memory>
 
 namespace {
 
-const char* kTestName = "LockUnlock";
-
 // MicroLock
 const size_t kMicroLockPassCount = 2000000000;
-const char* kMicroLockBenchmarkName = "FollyMicroLock";
 typedef folly::MicroLock MicroLock;
 
 // MicroSpinLock
 const size_t kMicroSpinLockPassCount = 1500000000;
-const char* kMicroSpinLockBenchmarkName = "FollyMicroSpinLock";
 typedef folly::MicroSpinLock MicroSpinLock;
 
 // PicoSpinLock
 const size_t kPicoSpinLockPassCount = 2700000000;
-const char* kPicoSpinLockBenchmarkName = "FollyPicoSpinLock";
 typedef folly::PicoSpinLock<size_t> PicoSpinLock;
 
 // SharedMutex
 const size_t kSharedMutexPassCount = 5000000;
-const char* kSharedMutexReadPriorityBenchmarkName =
-    "FollySharedMutex_ReadPriority";
-const char* kSharedMutexWritePriorityBenchmarkName =
-    "FollySharedMutex_WritePriority";
 typedef folly::SharedMutexReadPriority SharedMutexReadPriority;
 typedef folly::SharedMutexWritePriority SharedMutexWritePriority;
 
 // RWSpinLock
 const size_t kRWSpinLockPassCount = 5000000;
-const char* kRWSpinLockBenchmarkName = "FollyRWSpinLock";
 typedef folly::RWSpinLock RWSpinLock;
 
 // RWTicketSpinLock
 const size_t kRWTicketSpinLockPassCount = 5000000;
-const char* kRWTicketSpinLock32BenchmarkName = "FollyRWTicketSpinLock_32";
-const char* kRWTicketSpinLock64BenchmarkName = "FollyRWTicketSpinLock_64";
 typedef folly::RWTicketSpinLock32 RWTicketSpinLock32;
 typedef folly::RWTicketSpinLock64 RWTicketSpinLock64;
 
 // RCU
 const size_t kRcuSyncPassCount = 180000;
 const size_t kRcuNoSyncPassCount = 3500000;
-const char* kRcuSyncBenchmarkName = "FollyRCU_Sync";
-const char* kRcuNoSyncBenchmarkName = "FollyRCU_NoSync";
 // Represent the RCU-protected data.
 struct RcuFoo {
   size_t f1;
@@ -61,10 +46,7 @@ struct RcuFoo {
 
 }
 
-void run_rcu_sync(size_t pass_count, const char* bench_name) {
-  std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-  auto start_time = std::chrono::system_clock::now();
-
+void run_rcu_sync(size_t pass_count) {
   for (int write_percentage = 1; write_percentage <= 5; write_percentage += 1) {
     for (size_t count = 0; count < pass_count; count++) {
       for (int i = 0; i < 100; ++i) {
@@ -78,18 +60,9 @@ void run_rcu_sync(size_t pass_count, const char* bench_name) {
       }
     }
   }
-
-  auto finish_time = std::chrono::system_clock::now();
-  auto dur = finish_time - start_time;
-  auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-  std::cout << "[       OK ] " << kTestName << "." << bench_name
-            << " (" << milisecs.count() << " ms)" << std::endl;
 }
 
-void run_rcu_no_sync(size_t pass_count, const char* bench_name) {
-  std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-  auto start_time = std::chrono::system_clock::now();
-
+void run_rcu_no_sync(size_t pass_count) {
   for (int write_percentage = 1; write_percentage <= 5; write_percentage += 1) {
     for (size_t count = 0; count < pass_count; count++) {
       for (int i = 0; i < 100; ++i) {
@@ -102,19 +75,10 @@ void run_rcu_no_sync(size_t pass_count, const char* bench_name) {
       }
     }
   }
-
-  auto finish_time = std::chrono::system_clock::now();
-  auto dur = finish_time - start_time;
-  auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-  std::cout << "[       OK ] " << kTestName << "." << bench_name
-            << " (" << milisecs.count() << " ms)" << std::endl;
 }
 
 template <typename Lock>
-void run_rw_lock(size_t pass_count, const char* bench_name) {
-  std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-  auto start_time = std::chrono::system_clock::now();
-
+void run_rw_lock(size_t pass_count) {
   std::unique_ptr<Lock> l(new Lock());
   for (int write_percentage = 5; write_percentage < 20; write_percentage += 5) {
     for (size_t count = 0; count < pass_count; count++) {
@@ -129,57 +93,65 @@ void run_rw_lock(size_t pass_count, const char* bench_name) {
       }
     }
   }
-
-  auto finish_time = std::chrono::system_clock::now();
-  auto dur = finish_time - start_time;
-  auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-  std::cout << "[       OK ] " << kTestName << "." << bench_name
-            << " (" << milisecs.count() << " ms)" << std::endl;
 }
 
 template <typename Lock>
-void run_small_lock(Lock* l, size_t pass_count, const char* bench_name) {
-    std::cout << "[ RUN      ] " << kTestName << "." << bench_name << std::endl;
-    auto start_time = std::chrono::system_clock::now();
+void run_small_lock(size_t pass_count) {
+  std::unique_ptr<Lock> l(new Lock());
+  l->init();
+  for (size_t count = 0; count < pass_count; count++) {
+    l->lock();
+    l->unlock();
+  }
+}
 
-    for (size_t count = 0; count < pass_count; count++) {
-      l->lock();
-      l->unlock();
-    }
-    auto finish_time = std::chrono::system_clock::now();
-    auto dur = finish_time - start_time;
-    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
-    std::cout << "[       OK ] " << kTestName << "." << bench_name
-              << " (" << milisecs.count() << " ms)" << std::endl;
+class FollySyncTest: public ::testing::Test {
+
+};
+
+TEST_F(FollySyncTest, FollyRCU_Sync) {
+  run_rcu_sync(kRcuSyncPassCount);
 }
 
-template <typename Lock>
-void init_run_lock(size_t pass_count, const char* bench_name) {
-  std::unique_ptr<Lock> l(new Lock());
-  l->init();
-  run_small_lock<Lock>(l.get(), pass_count, bench_name);
+TEST_F(FollySyncTest, FollyRCU_NoSync) {
+  run_rcu_no_sync(kRcuNoSyncPassCount);
+}
+
+TEST_F(FollySyncTest, FollyRWTicketSpinLock_32) {
+  run_rw_lock<RWTicketSpinLock32>(kRWTicketSpinLockPassCount);
+}
+
+TEST_F(FollySyncTest, FollyRWTicketSpinLock_64) {
+  run_rw_lock<RWTicketSpinLock64>(kRWTicketSpinLockPassCount);
 }
 
-int main() {
-  run_rcu_sync(kRcuSyncPassCount, kRcuSyncBenchmarkName);
-  run_rcu_no_sync(kRcuNoSyncPassCount, kRcuNoSyncBenchmarkName);
+TEST_F(FollySyncTest, FollyRWSpinLock) {
+  run_rw_lock<RWSpinLock>(kRWSpinLockPassCount);
+}
+
+TEST_F(FollySyncTest, FollySharedMutex_ReadPriority) {
+  run_rw_lock<SharedMutexReadPriority>(kSharedMutexPassCount);
+}
+
+TEST_F(FollySyncTest, FollySharedMutex_WritePriority) {
+  run_rw_lock<SharedMutexWritePriority>(kSharedMutexPassCount);
+}
 
-  run_rw_lock<RWTicketSpinLock32>(kRWTicketSpinLockPassCount,
-                                  kRWTicketSpinLock32BenchmarkName);
-  run_rw_lock<RWTicketSpinLock64>(kRWTicketSpinLockPassCount,
-                                  kRWTicketSpinLock64BenchmarkName);
+TEST_F(FollySyncTest, FollyMicroSpinLock) {
+  run_small_lock<MicroSpinLock>(kMicroSpinLockPassCount);
+}
 
-  run_rw_lock<RWSpinLock>(kRWSpinLockPassCount, kRWSpinLockBenchmarkName);
+TEST_F(FollySyncTest, FollyPicoSpinLock) {
+  run_small_lock<PicoSpinLock>(kPicoSpinLockPassCount);
+}
 
-  run_rw_lock<SharedMutexReadPriority>(
-      kSharedMutexPassCount, kSharedMutexReadPriorityBenchmarkName);
-  run_rw_lock<SharedMutexWritePriority>(
-      kSharedMutexPassCount, kSharedMutexWritePriorityBenchmarkName);
+TEST_F(FollySyncTest, FollyMicroLock) {
+  run_small_lock<MicroLock>(kMicroLockPassCount);
+}
 
-  init_run_lock<MicroSpinLock>(kMicroSpinLockPassCount,
-                               kMicroSpinLockBenchmarkName);
-  init_run_lock<PicoSpinLock>(kPicoSpinLockPassCount,
-                              kPicoSpinLockBenchmarkName);
-  init_run_lock<MicroLock>(kMicroLockPassCount, kMicroLockBenchmarkName);
-  return 0;
+int main(int argc, char** argv) {
+  // Init Google test
+  ::testing::InitGoogleTest(&argc, argv);
+  int result = RUN_ALL_TESTS();
+  return result;
 }