/*
- * 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.
#include <thread>
#include <glog/logging.h>
-#include <gtest/gtest.h>
#include <folly/Benchmark.h>
#include <folly/Hash.h>
#include <folly/portability/GFlags.h>
+#include <folly/portability/GTest.h>
+#include <folly/system/ThreadId.h>
using namespace folly;
std::vector<std::thread> threads; \
for (int i = 0; i < FLAGS_numThreads; ++i) { \
threads.push_back(std::thread([&]() { \
- for (int i = 0; i < iterPerThread; ++i) { \
+ for (int j = 0; j < iterPerThread; ++j) { \
inc_stmt; \
} \
})); \
std::atomic<int64_t> ints_[kBuckets_];
inline void inc(int64_t val = 1) {
- int bucket = hash::twang_mix64(
- uint64_t(pthread_self())) & (kBuckets_ - 1);
- std::atomic_fetch_add(&ints_[bucket], val);
+ int buck = hash::twang_mix64(folly::getCurrentThreadID()) & (kBuckets_ - 1);
+ std::atomic_fetch_add(&ints_[buck], val);
}
// read the first few and extrapolate