folly: improve Subprocess::enforce() error message
[folly.git] / folly / Benchmark.h
index 444ad81d216a87325911d1d66121f2c5ce7c17d9..5e155f2851f3b726ecf246411e3e75a232abce71 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2013 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -185,16 +185,19 @@ typename std::enable_if<
   == 2
 >::type
 addBenchmark(const char* file, const char* name, Lambda&& lambda) {
-  auto execute = [=](unsigned int times) {
+  auto execute = [=](unsigned int times) -> uint64_t {
     BenchmarkSuspender::nsSpent = 0;
     timespec start, end;
 
     // CORE MEASUREMENT STARTS
-    CHECK_EQ(0, clock_gettime(detail::DEFAULT_CLOCK_ID, &start));
+    auto const r1 = clock_gettime(detail::DEFAULT_CLOCK_ID, &start);
     lambda(times);
-    CHECK_EQ(0, clock_gettime(detail::DEFAULT_CLOCK_ID, &end));
+    auto const r2 = clock_gettime(detail::DEFAULT_CLOCK_ID, &end);
     // CORE MEASUREMENT ENDS
 
+    CHECK_EQ(0, r1);
+    CHECK_EQ(0, r2);
+
     return detail::timespecDiff(end, start) - BenchmarkSuspender::nsSpent;
   };