fix gcc-5 build
authorIgor Sugak <sugak@fb.com>
Fri, 6 Jan 2017 17:53:00 +0000 (09:53 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 6 Jan 2017 18:03:24 +0000 (10:03 -0800)
Summary:
```lang=bash
folly/test/SmallLocksBenchmark.cpp:212:18: error: use of undeclared identifier 'sqrt'
  double stdev = sqrt(accum / (results.size() - 1));
                 ^
folly/test/SmallLocksBenchmark.cpp:221:20: error: use of undeclared identifier 'sqrt'
  double stddev2 = sqrt(variance);
                   ^
2 errors generated.
```
Add the missing header.

Reviewed By: yfeldblum

Differential Revision: D4386343

fbshipit-source-id: 79c3dcae32c62f9b6d162862deabccf5fea7eaef

folly/test/SmallLocksBenchmark.cpp

index db027e535eec9cd31724cecc321f431a497a8150..b3568d06d409b2d225988a63008ca83be7a6fbc8 100644 (file)
  * limitations under the License.
  */
 
-#include <folly/Benchmark.h>
-#include <folly/SmallLocks.h>
 #include <algorithm>
+#include <cmath>
 #include <condition_variable>
 #include <numeric>
 #include <thread>
 #include <vector>
 
+#include <folly/Benchmark.h>
+#include <folly/SmallLocks.h>
+
 /* "Work cycle" is just an additional nop loop iteration.
  * A smaller number of work cyles will result in more contention,
  * which is what we're trying to measure.  The relative ratio of
@@ -209,7 +211,7 @@ static void runFairness() {
   std::for_each(results.begin(), results.end(), [&](const double d) {
     accum += (d - m) * (d - m);
   });
-  double stdev = sqrt(accum / (results.size() - 1));
+  double stdev = std::sqrt(accum / (results.size() - 1));
   std::chrono::microseconds mx = *std::max_element(maxes.begin(), maxes.end());
   std::chrono::microseconds agAqTime = std::accumulate(
       aqTime.begin(), aqTime.end(), std::chrono::microseconds(0));
@@ -218,7 +220,7 @@ static void runFairness() {
   std::chrono::microseconds mean = agAqTime / sum;
   double variance = (sum * agAqTimeSq - (agAqTime.count() * agAqTime.count())) /
       sum / (sum - 1);
-  double stddev2 = sqrt(variance);
+  double stddev2 = std::sqrt(variance);
 
   printf("Sum: %li Mean: %.0f stddev: %.0f\n", sum, m, stdev);
   printf(