proxygen
BatonBenchmark.cpp File Reference

Go to the source code of this file.

Functions

 BENCHMARK (baton_pingpong_blocking, iters)
 
 BENCHMARK (baton_pingpong_nonblocking, iters)
 
 BENCHMARK_DRAW_LINE ()
 
 BENCHMARK (baton_pingpong_emulated_futex_blocking, iters)
 
 BENCHMARK (baton_pingpong_emulated_futex_nonblocking, iters)
 
 BENCHMARK (posix_sem_pingpong, iters)
 
int main (int argc, char **argv)
 

Function Documentation

BENCHMARK ( baton_pingpong_blocking  ,
iters   
)

Definition at line 30 of file BatonBenchmark.cpp.

30  {
31  run_pingpong_test<true, std::atomic>(iters);
32 }
BENCHMARK ( baton_pingpong_nonblocking  ,
iters   
)

Definition at line 34 of file BatonBenchmark.cpp.

References folly::BENCHMARK_DRAW_LINE().

34  {
35  run_pingpong_test<false, std::atomic>(iters);
36 }
BENCHMARK ( baton_pingpong_emulated_futex_blocking  ,
iters   
)

Definition at line 40 of file BatonBenchmark.cpp.

40  {
41  run_pingpong_test<true, EmulatedFutexAtomic>(iters);
42 }
BENCHMARK ( baton_pingpong_emulated_futex_nonblocking  ,
iters   
)

Definition at line 44 of file BatonBenchmark.cpp.

References folly::BENCHMARK_DRAW_LINE().

44  {
45  run_pingpong_test<false, EmulatedFutexAtomic>(iters);
46 }
BENCHMARK ( posix_sem_pingpong  ,
iters   
)

Definition at line 50 of file BatonBenchmark.cpp.

References a, b, and i.

50  {
51  sem_t sems[3];
52  sem_t* a = sems + 0;
53  sem_t* b = sems + 2; // to get it on a different cache line
54 
55  sem_init(a, 0, 0);
56  sem_init(b, 0, 0);
57  auto thr = std::thread([=] {
58  for (size_t i = 0; i < iters; ++i) {
59  sem_wait(a);
60  sem_post(b);
61  }
62  });
63  for (size_t i = 0; i < iters; ++i) {
64  sem_post(a);
65  sem_wait(b);
66  }
67  thr.join();
68 }
char b
char a
BENCHMARK_DRAW_LINE ( )
int main ( int  argc,
char **  argv 
)

Definition at line 75 of file BatonBenchmark.cpp.

References folly::runBenchmarks().

75  {
76  gflags::ParseCommandLineFlags(&argc, &argv, true);
78  return 0;
79 }
void runBenchmarks()
Definition: Benchmark.cpp:456
char ** argv