#include <folly/ThreadLocal.h>
#include <sys/types.h>
#include <array>
#include <atomic>
#include <condition_variable>
#include <map>
#include <mutex>
#include <set>
#include <thread>
#include <boost/thread/tss.hpp>
#include <glog/logging.h>
#include <folly/Benchmark.h>
#include <folly/experimental/io/FsUtil.h>
#include <folly/portability/GFlags.h>
Go to the source code of this file.
|
| DEFINE_int32 (numThreads, 8,"Number simultaneous threads for benchmarks.") |
|
| BENCHMARK (FB_CONCATENATE(BM_mt_, tlp), iters) |
|
| BENCHMARK (FB_CONCATENATE(BM_mt_, pthread_get_specific), iters) |
|
| BENCHMARK (FB_CONCATENATE(BM_mt_, boost_tsp), iters) |
|
| BENCHMARK_DRAW_LINE () |
|
template<typename TL > |
void | run_multi (uint32_t iters) |
|
| BENCHMARK (BM_mt_tlp_multi, iters) |
|
| BENCHMARK (BM_mt_pthread_get_specific_multi, iters) |
|
| BENCHMARK (BM_mt_boost_tsp_multi, iters) |
|
int | main (int argc, char **argv) |
|
Value: const int itersPerThread = iters / FLAGS_numThreads; \
std::vector<std::thread>
threads; \
for (
int i = 0;
i < FLAGS_numThreads; ++
i) {
\ threads.push_back(std::thread([&]() { \
var.reset(new int(0)); \
for (int j = 0; j < itersPerThread; ++j) { \
++(*var.get()); \
} \
})); \
} \
for (
auto&
t : threads) {
\ } \
}
BENCHMARK(FB_CONCATENATE(BM_mt_, tlp), iters)
std::vector< std::thread::id > threads
#define FB_CONCATENATE(s1, s2)
Definition at line 64 of file ThreadLocalBenchmark.cpp.
BENCHMARK |
( |
BM_mt_tlp_multi |
, |
|
|
iters |
|
|
) |
| |
BENCHMARK |
( |
BM_mt_pthread_get_specific_multi |
, |
|
|
iters |
|
|
) |
| |
BENCHMARK |
( |
BM_mt_boost_tsp_multi |
, |
|
|
iters |
|
|
) |
| |
DEFINE_int32 |
( |
numThreads |
, |
|
|
8 |
, |
|
|
"Number simultaneous threads for benchmarks." |
|
|
) |
| |
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 95 of file ThreadLocalBenchmark.cpp.
References i, folly::pushmi::detail::t, and threads.
96 const int itersPerThread = iters / FLAGS_numThreads;
97 std::vector<std::thread>
threads;
99 for (
int i = 0;
i < FLAGS_numThreads; ++
i) {
100 threads.push_back(std::thread([&]() {
102 for (
int j = 0; j < itersPerThread; ++j) {
104 var.get()->b += var.get()->a;
106 var.get()->b += var.get()->a;
110 for (
auto&
t : threads) {
std::vector< std::thread::id > threads
boost::thread_specific_ptr<int> boost_tsp |