proxygen
|
#include <folly/Portability.h>
#include <folly/Preprocessor.h>
#include <folly/ScopeGuard.h>
#include <folly/Traits.h>
#include <folly/functional/Invoke.h>
#include <folly/portability/GFlags.h>
#include <cassert>
#include <chrono>
#include <functional>
#include <limits>
#include <type_traits>
#include <boost/function_types/function_arity.hpp>
#include <glog/logging.h>
Go to the source code of this file.
Classes | |
struct | folly::detail::BenchmarkRegistration |
struct | folly::detail::BenchmarkResult |
struct | folly::BenchmarkSuspender |
struct | folly::detail::DoNotOptimizeAwayNeedsIndirect< T > |
Namespaces | |
folly | |
—— Concurrent Priority Queue Implementation —— | |
folly::detail | |
Macros | |
#define | BENCHMARK_IMPL(funName, stringName, rv, paramType, paramName) |
#define | BENCHMARK_MULTI_IMPL(funName, stringName, paramType, paramName) |
#define | BENCHMARK(name, ...) |
#define | BENCHMARK_MULTI(name, ...) |
#define | BENCHMARK_PARAM(name, param) BENCHMARK_NAMED_PARAM(name, param, param) |
#define | BENCHMARK_PARAM_MULTI(name, param) BENCHMARK_NAMED_PARAM_MULTI(name, param, param) |
#define | BENCHMARK_NAMED_PARAM(name, param_name, ...) |
#define | BENCHMARK_NAMED_PARAM_MULTI(name, param_name, ...) |
#define | BENCHMARK_RELATIVE(name, ...) |
#define | BENCHMARK_RELATIVE_MULTI(name, ...) |
#define | BENCHMARK_RELATIVE_PARAM(name, param) BENCHMARK_RELATIVE_NAMED_PARAM(name, param, param) |
#define | BENCHMARK_RELATIVE_PARAM_MULTI(name, param) BENCHMARK_RELATIVE_NAMED_PARAM_MULTI(name, param, param) |
#define | BENCHMARK_RELATIVE_NAMED_PARAM(name, param_name, ...) |
#define | BENCHMARK_RELATIVE_NAMED_PARAM_MULTI(name, param_name, ...) |
#define | BENCHMARK_DRAW_LINE() |
#define | BENCHMARK_SUSPEND |
Typedefs | |
using | folly::detail::TimeIterPair = std::pair< std::chrono::high_resolution_clock::duration, unsigned int > |
using | folly::detail::BenchmarkFun = std::function< detail::TimeIterPair(unsigned int)> |
Functions | |
DECLARE_bool (benchmark) | |
void | folly::runBenchmarks () |
bool | folly::runBenchmarksOnFlag () |
void | folly::detail::addBenchmarkImpl (const char *file, const char *name, std::function< TimeIterPair(unsigned int)>) |
template<typename Lambda > | |
std::enable_if< boost::function_types::function_arity< decltype(&Lambda::operator())>::value==2 >::type | folly::addBenchmark (const char *file, const char *name, Lambda &&lambda) |
template<typename Lambda > | |
std::enable_if< boost::function_types::function_arity< decltype(&Lambda::operator())>::value==1 >::type | folly::addBenchmark (const char *file, const char *name, Lambda &&lambda) |
template<typename T > | |
auto | folly::doNotOptimizeAway (const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type |
template<typename T > | |
auto | folly::makeUnpredictable (T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type |
void | folly::benchmarkResultsToDynamic (const vector< detail::BenchmarkResult > &data, dynamic &out) |
void | folly::benchmarkResultsFromDynamic (const dynamic &d, vector< detail::BenchmarkResult > &results) |
void | folly::printResultComparison (const vector< detail::BenchmarkResult > &base, const vector< detail::BenchmarkResult > &test) |
#define BENCHMARK | ( | name, | |
... | |||
) |
Introduces a benchmark function. Use with either one or two arguments. The first is the name of the benchmark. Use something descriptive, such as insertVectorBegin. The second argument may be missing, or could be a symbolic counter. The counter dictates how many internal iteration the benchmark does. Example:
BENCHMARK(vectorPushBack) { vector<int> v; v.push_back(42); }
BENCHMARK(insertVectorBegin, n) { vector<int> v; FOR_EACH_RANGE (i, 0, n) { v.insert(v.begin(), 42); } }
Definition at line 365 of file Benchmark.h.
BENCHMARK_DRAW_LINE | ( | ) |
Draws a line of dashes.
Definition at line 557 of file Benchmark.h.
#define BENCHMARK_IMPL | ( | funName, | |
stringName, | |||
rv, | |||
paramType, | |||
paramName | |||
) |
Introduces a benchmark function. Used internally, see BENCHMARK and friends below.
Definition at line 318 of file Benchmark.h.
#define BENCHMARK_MULTI | ( | name, | |
... | |||
) |
Like BENCHMARK above, but allows the user to return the actual number of iterations executed in the function body. This can be useful if the benchmark function doesn't know upfront how many iterations it's going to run or if it runs through a certain number of test cases, e.g.:
BENCHMARK_MULTI(benchmarkSomething) { std::vector<int> testCases { 0, 1, 1, 2, 3, 5 }; for (int c : testCases) { doSomething(c); } return testCases.size(); }
Definition at line 388 of file Benchmark.h.
#define BENCHMARK_MULTI_IMPL | ( | funName, | |
stringName, | |||
paramType, | |||
paramName | |||
) |
Introduces a benchmark function with support for returning the actual number of iterations. Used internally, see BENCHMARK_MULTI and friends below.
Definition at line 336 of file Benchmark.h.
#define BENCHMARK_NAMED_PARAM | ( | name, | |
param_name, | |||
... | |||
) |
Definition at line 449 of file Benchmark.h.
Referenced by addValue(), benchmarkGet(), benchmarkSet(), contendedRW(), contendedUse(), contentionAtWidthCached(), and estimateQuantile().
#define BENCHMARK_NAMED_PARAM_MULTI | ( | name, | |
param_name, | |||
... | |||
) |
Same as BENCHMARK_NAMED_PARAM, but allows one to return the actual number of iterations that have been run.
Definition at line 463 of file Benchmark.h.
Referenced by append(), Skip_ForwardQ128(), and SkipTo_SkipQ128().
#define BENCHMARK_PARAM | ( | name, | |
param | |||
) | BENCHMARK_NAMED_PARAM(name, param, param) |
Defines a benchmark that passes a parameter to another one. This is common for benchmarks that need a "problem size" in addition to "number of iterations". Consider:
void pushBack(uint32_t n, size_t initialSize) { vector<int> v; BENCHMARK_SUSPEND { v.resize(initialSize); } FOR_EACH_RANGE (i, 0, n) { v.push_back(i); } } BENCHMARK_PARAM(pushBack, 0) BENCHMARK_PARAM(pushBack, 1000) BENCHMARK_PARAM(pushBack, 1000000)
The benchmark above estimates the speed of push_back at different initial sizes of the vector. The framework will pass 0, 1000, and 1000000 for initialSize, and the iteration count for n.
Definition at line 417 of file Benchmark.h.
Referenced by assignmentFill(), assignmentOp(), copyCtor(), ctorFromArray(), ctorFromChar(), ctorFromTwoPointers(), defaultCtor(), equality(), fillCtor(), findSuccessful(), findUnsuccessful(), getline(), initRNG(), insertFront(), Lines_Gen(), notifyInlineObservers(), push_back(), pushBack(), replace(), reserve(), resize(), runTest(), runTestDiffTag(), short_append(), sizeCtor(), stringPrintfOutputSize(), StringUnsplit_Gen(), and zeroCopyOffMulti().
#define BENCHMARK_PARAM_MULTI | ( | name, | |
param | |||
) | BENCHMARK_NAMED_PARAM_MULTI(name, param, param) |
Same as BENCHMARK_PARAM, but allows one to return the actual number of iterations that have been run.
Definition at line 423 of file Benchmark.h.
Referenced by paramMultiRel().
#define BENCHMARK_RELATIVE | ( | name, | |
... | |||
) |
Just like BENCHMARK, but prints the time relative to a baseline. The baseline is the most recent BENCHMARK() seen in the current scope. Example:
// This is the baseline BENCHMARK(insertVectorBegin, n) { vector<int> v; FOR_EACH_RANGE (i, 0, n) { v.insert(v.begin(), 42); } }
BENCHMARK_RELATIVE(insertListBegin, n) { list<int> s; FOR_EACH_RANGE (i, 0, n) { s.insert(s.begin(), 42); } }
Any number of relative benchmark can be associated with a baseline. Another BENCHMARK() occurrence effectively establishes a new baseline.
Definition at line 496 of file Benchmark.h.
#define BENCHMARK_RELATIVE_MULTI | ( | name, | |
... | |||
) |
Same as BENCHMARK_RELATIVE, but allows one to return the actual number of iterations that have been run.
Definition at line 508 of file Benchmark.h.
#define BENCHMARK_RELATIVE_NAMED_PARAM | ( | name, | |
param_name, | |||
... | |||
) |
A combination of BENCHMARK_RELATIVE and BENCHMARK_NAMED_PARAM.
Definition at line 531 of file Benchmark.h.
Referenced by benchmarkGet(), benchmarkSet(), and estimateQuantile().
#define BENCHMARK_RELATIVE_NAMED_PARAM_MULTI | ( | name, | |
param_name, | |||
... | |||
) |
Same as BENCHMARK_RELATIVE_NAMED_PARAM, but allows one to return the actual number of iterations that have been run.
Definition at line 545 of file Benchmark.h.
Referenced by append().
#define BENCHMARK_RELATIVE_PARAM | ( | name, | |
param | |||
) | BENCHMARK_RELATIVE_NAMED_PARAM(name, param, param) |
A combination of BENCHMARK_RELATIVE and BENCHMARK_PARAM.
Definition at line 518 of file Benchmark.h.
Referenced by Lines_Gen(), notifyInlineObservers(), and StringUnsplit_Gen().
#define BENCHMARK_RELATIVE_PARAM_MULTI | ( | name, | |
param | |||
) | BENCHMARK_RELATIVE_NAMED_PARAM_MULTI(name, param, param) |
Same as BENCHMARK_RELATIVE_PARAM, but allows one to return the actual number of iterations that have been run.
Definition at line 525 of file Benchmark.h.
Referenced by paramMultiRel().
#define BENCHMARK_SUSPEND |
Allows execution of code that doesn't count torward the benchmark's time budget. Example:
BENCHMARK_START_GROUP(insertVectorBegin, n) { vector<int> v; BENCHMARK_SUSPEND { v.reserve(n); } FOR_EACH_RANGE (i, 0, n) { v.insert(v.begin(), 42); } }
Definition at line 576 of file Benchmark.h.
Referenced by append(), assignmentOp(), BENCHMARK(), BENCHMARK_RELATIVE(), benchmarkSet(), contendedRW(), contendedUse(), copyCtor(), ctorFromArray(), ctorFromTwoPointers(), encryptGCM(), equality(), estimateQuantile(), folly::test::fc_test(), findSuccessful(), findUnsuccessful(), getline(), merge(), mergeDigests(), StringIdenticalToBM< String >::operator()(), StringVariadicToBM< String >::operator()(), preallocate_postallocate_bench(), replace(), runAllAndValidate(), runContendedReaders(), runMixed(), runPingPong(), runRemoteUnlock(), stringPrintfOutputSize(), and StringUnsplit_Gen().
DECLARE_bool | ( | benchmark | ) |