proxygen
DigestBuilderBenchmark.cpp File Reference
#include <folly/stats/detail/DigestBuilder-defs.h>
#include <chrono>
#include <condition_variable>
#include <thread>
#include <boost/thread/barrier.hpp>
#include <folly/Benchmark.h>
#include <folly/Range.h>
#include <folly/portability/GFlags.h>

Go to the source code of this file.

Classes

class  FreeDigest
 

Functions

 DEFINE_int32 (digest_merge_time_ns, 5500,"Time to merge into the digest")
 
unsigned int append (unsigned int iters, size_t bufSize, size_t nThreads)
 
 BENCHMARK_DRAW_LINE ()
 
int main (int argc, char *argv[])
 

Function Documentation

unsigned int append ( unsigned int  iters,
size_t  bufSize,
size_t  nThreads 
)

Definition at line 47 of file DigestBuilderBenchmark.cpp.

References folly::BENCHMARK_DRAW_LINE(), BENCHMARK_NAMED_PARAM_MULTI, BENCHMARK_RELATIVE_NAMED_PARAM_MULTI, BENCHMARK_SUSPEND, buffer(), i, and threads.

47  {
48  iters = 1000000;
49  auto buffer = std::make_shared<DigestBuilder<FreeDigest>>(bufSize, 100);
50 
51  auto barrier = std::make_shared<boost::barrier>(nThreads + 1);
52 
53  std::vector<std::thread> threads;
54  threads.reserve(nThreads);
56  for (size_t i = 0; i < nThreads; ++i) {
57  threads.emplace_back([&]() {
58  barrier->wait();
59  for (size_t iter = 0; iter < iters; ++iter) {
60  buffer->append(iter);
61  }
62  barrier->wait();
63  });
64  }
65  barrier->wait();
66  }
67  barrier->wait();
68 
70  for (auto& thread : threads) {
71  thread.join();
72  }
73  }
74  return iters;
75 }
std::vector< uint8_t > buffer(kBufferSize+16)
#define BENCHMARK_SUSPEND
Definition: Benchmark.h:576
std::vector< std::thread::id > threads
BENCHMARK_DRAW_LINE ( )
DEFINE_int32 ( digest_merge_time_ns  ,
5500  ,
"Time to merge into the digest"   
)
int main ( int  argc,
char *  argv[] 
)

Definition at line 112 of file DigestBuilderBenchmark.cpp.

References argv, and folly::runBenchmarks().

112  {
113  gflags::ParseCommandLineFlags(&argc, &argv, true);
115  return 0;
116 }
void runBenchmarks()
Definition: Benchmark.cpp:456
char ** argv