X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FSmallLocksBenchmark.cpp;h=8a1d6a35cc522e3b721d9b5c31cd60ee6b6d31e2;hb=a60bf0bb374f4b57c0f00cd862e2861e1f381ed0;hp=9b86adf3b57de816e38f492170eba24cddaf35ab;hpb=efc07505fad326d69aa0f96b8d2e74c722dd98a5;p=folly.git diff --git a/folly/test/SmallLocksBenchmark.cpp b/folly/test/SmallLocksBenchmark.cpp index 9b86adf3..8a1d6a35 100644 --- a/folly/test/SmallLocksBenchmark.cpp +++ b/folly/test/SmallLocksBenchmark.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,16 @@ * limitations under the License. */ -#include -#include #include +#include #include #include #include #include +#include +#include + /* "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 @@ -51,7 +53,7 @@ struct SimpleBarrier { if (++num_ == count_) { cv_.notify_all(); } else { - cv_.wait(lockHeld); + cv_.wait(lockHeld, [&]() { return num_ >= count_; }); } } @@ -104,7 +106,7 @@ static void runContended(size_t numOps, size_t numThreads) { SimpleBarrier runbarrier(totalthreads + 1); for (size_t t = 0; t < totalthreads; ++t) { - threads[t] = std::thread([&, t, totalthreads] { + threads[t] = std::thread([&, t] { lockstruct* lock = &locks[t % threadgroups]; runbarrier.wait(); for (size_t op = 0; op < numOps; op += 1) { @@ -157,7 +159,7 @@ static void runFairness() { SimpleBarrier runbarrier(totalthreads + 1); for (size_t t = 0; t < totalthreads; ++t) { - threads[t] = std::thread([&, t, totalthreads] { + threads[t] = std::thread([&, t] { lockstruct* lock = &locks[t % threadgroups]; long value = 0; std::chrono::microseconds max(0); @@ -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( @@ -272,7 +274,7 @@ struct VirtualBase { struct VirtualImpl : VirtualBase { void foo() override { /* noop */ } - virtual ~VirtualImpl() {} + ~VirtualImpl() override {} }; #ifndef __clang__