Commit 8869d108 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

SingletonThreadLocal benchmark

Summary: SingletonThreadLocal benchmark

Reviewed By: yfeldblum

Differential Revision: D15116981

fbshipit-source-id: cf44104542614ee9b79a88a14182c2ddbaf7a34c
parent d1677802
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <folly/Benchmark.h> #include <folly/Benchmark.h>
#include <folly/Memory.h> #include <folly/Memory.h>
#include <folly/SingletonThreadLocal.h>
#include <folly/portability/GFlags.h> #include <folly/portability/GFlags.h>
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations") FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
...@@ -139,6 +140,20 @@ BENCHMARK(FollySingletonTryGetFast4Threads, n) { ...@@ -139,6 +140,20 @@ BENCHMARK(FollySingletonTryGetFast4Threads, n) {
run4Threads([=]() { follySingletonTryGetFast(n); }); run4Threads([=]() { follySingletonTryGetFast(n); });
} }
void follySingletonThreadLocal(size_t n) {
for (size_t i = 0; i < n; ++i) {
folly::SingletonThreadLocal<BenchmarkSingleton, GetTag>::get().val++;
}
}
BENCHMARK(FollySingletonThreadLocal, n) {
follySingletonThreadLocal(n);
}
BENCHMARK(FollySingletonThreadLocal4Threads, n) {
run4Threads([=]() { follySingletonThreadLocal(n); });
}
int main(int argc, char** argv) { int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true); gflags::ParseCommandLineFlags(&argc, &argv, true);
gflags::SetCommandLineOptionWithMode( gflags::SetCommandLineOptionWithMode(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment