proxygen
ExceptionTracerBenchmark.cpp File Reference
#include <stdexcept>
#include <thread>
#include <vector>
#include <glog/logging.h>
#include <folly/Benchmark.h>
#include <folly/experimental/exception_tracer/ExceptionTracer.h>
#include <folly/portability/GFlags.h>

Go to the source code of this file.

Functions

void recurse (int level)
 
void loop (int iters)
 
 BENCHMARK (ExceptionTracer, iters)
 
int main (int argc, char *argv[])
 

Function Documentation

BENCHMARK ( ExceptionTracer  ,
iters   
)

Definition at line 45 of file ExceptionTracerBenchmark.cpp.

References kNumThreads, loop(), folly::pushmi::detail::t, and threads.

45  {
46  std::vector<std::thread> threads;
47  constexpr size_t kNumThreads = 10;
48  threads.resize(kNumThreads);
49  for (auto& t : threads) {
50  t = std::thread([iters]() { loop(iters); });
51  }
52  for (auto& t : threads) {
53  t.join();
54  }
55 }
static size_t const kNumThreads
std::vector< std::thread::id > threads
void loop(int iters)
void loop ( int  iters)

Definition at line 35 of file ExceptionTracerBenchmark.cpp.

References folly::exception_tracer::getCurrentExceptions(), i, and recurse().

Referenced by BENCHMARK(), folly::EventBase::EventBase(), fizz::tool::fizzServerCommand(), main(), runBenchmark(), and TEST_F().

35  {
36  for (int i = 0; i < iters * 100; ++i) {
37  try {
38  recurse(100);
39  } catch (const std::exception& e) {
41  }
42  }
43 }
std::vector< ExceptionInfo > getCurrentExceptions()
void recurse(int level)
int main ( int  argc,
char *  argv[] 
)

Definition at line 57 of file ExceptionTracerBenchmark.cpp.

References folly::runBenchmarks().

57  {
58  gflags::ParseCommandLineFlags(&argc, &argv, true);
59  google::InitGoogleLogging(argv[0]);
61  return 0;
62 }
void runBenchmarks()
Definition: Benchmark.cpp:456
char ** argv
void recurse ( int  level)

Definition at line 27 of file ExceptionTracerBenchmark.cpp.

References folly::doNotOptimizeAway().

Referenced by loop().

27  {
28  if (level == 0) {
29  throw std::runtime_error("");
30  }
31  recurse(level - 1);
32  folly::doNotOptimizeAway(0); // prevent tail recursion
33 }
void recurse(int level)
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
Definition: Benchmark.h:258