/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2016-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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
size_t num_{0};
size_t count_;
};
-}
+} // namespace
template <typename Lock>
class InitLock {
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) {
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);
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));
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(
struct VirtualImpl : VirtualBase {
void foo() override { /* noop */
}
- virtual ~VirtualImpl() {}
+ ~VirtualImpl() override {}
};
#ifndef __clang__