• Home
  • Raw
  • Download

Lines Matching full:benchmark

20 static void BM_StringCreation(benchmark::State& state) {
25 // Register the function as a benchmark
26 BENCHMARK(BM_StringCreation);
28 // Define another benchmark
29 static void BM_StringCopy(benchmark::State& state) {
34 BENCHMARK(BM_StringCopy);
43 benchmark::Initialize(&argc, argv);
44 benchmark::RunSpecifiedBenchmarks();
54 static void BM_memcpy(benchmark::State& state) {
63 BENCHMARK(BM_memcpy)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10);
69 BENCHMARK(BM_memcpy)->Range(8, 8<<10);
74 static void BM_SetInsert(benchmark::State& state) {
84 BENCHMARK(BM_SetInsert)
98 BENCHMARK(BM_SetInsert)->Ranges({{1<<10, 8<<10}, {128, 512}});
105 static void CustomArguments(benchmark::internal::Benchmark* b) {
110 BENCHMARK(BM_SetInsert)->Apply(CustomArguments);
115 template <class Q> int BM_Sequential(benchmark::State& state) {
130 Use `Benchmark::MinTime(double t)` to set the minimum time used to run the
131 benchmark. This option overrides the `benchmark_min_time` flag.
133 void BM_test(benchmark::State& state) {
136 BENCHMARK(BM_test)->MinTime(2.0); // Run for at least 2 seconds.
143 static void BM_MultiThreaded(benchmark::State& state) {
154 BENCHMARK(BM_MultiThreaded)->Threads(4);
157 If a benchmark runs a few milliseconds it may be hard to visually compare the
161 BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
256 namespace benchmark {
268 // of each matching benchmark. Otherwise run each matching benchmark and
284 // allocation measurements for benchmark runs.
288 class Benchmark; variable
294 // Take ownership of the pointer and register the benchmark. Return the
295 // registered benchmark.
296 Benchmark* RegisterBenchmarkInternal(Benchmark*);
355 // by the duration of the benchmark.
367 // and then divided by the duration of the benchmark.
406 // TimeUnit is passed to a benchmark in order to specify the order of magnitude
410 // BigO is passed to a benchmark in order to specify the asymptotic
412 // complexity for the benchmark. In case oAuto is selected, complexity will be
416 // BigOFunc is passed to a benchmark in order to specify the asymptotic
417 // computational complexity for the benchmark.
420 // StatisticsFunc is passed to a benchmark in order to compute some descriptive
459 // State is passed to a running Benchmark and contains state for the
460 // benchmark to use.
466 // Returns iterators used to run each iteration of a benchmark using a
469 // REQUIRES: The benchmark has not started running yet. Neither begin nor end
476 // Returns true if the benchmark should continue through another iteration.
477 // NOTE: A benchmark may not return from the test until KeepRunning() has
481 // Returns true iff the benchmark should run n more iterations.
483 // NOTE: A benchmark must not return from the test until KeepRunningBatch()
495 // Stop the benchmark timer. If not called, the timer will be
496 // automatically stopped after the last iteration of the benchmark loop.
506 // within each benchmark iteration, if possible.
511 // Start the benchmark timer. The timer is NOT running on entrance to the
512 // benchmark function. It begins running after control flow enters the
513 // benchmark loop.
517 // within each benchmark iteration, if possible.
522 // Report the benchmark as resulting in an error with the specified 'msg'.
523 // After this call the user may explicitly 'return' from the benchmark.
525 // If the ranged-for style of benchmark loop is used, the user must explicitly
535 // NOTE: Calling 'SkipWithError(...)' does not cause the benchmark to exit
542 // Set the manually measured time for this benchmark iteration, which
550 // Set the number of bytes processed by the current benchmark
552 // throughput oriented benchmark.
554 // REQUIRES: a benchmark has exited its benchmarking loop.
570 // family benchmark, then current benchmark will be part of the computation
580 // label is printed on the benchmark report line for the currently
581 // executing benchmark. It is typically called at the end of a processing
582 // benchmark where a processing items/second output is desired.
584 // REQUIRES: a benchmark has exited its benchmarking loop.
588 Counter(static_cast<double>(items), benchmark::Counter::kIsRate); in SetItemsProcessed()
599 // end of the benchmark report line for the currently executing
600 // benchmark. Example:
601 // static void BM_Compress(benchmark::State& state) {
609 // REQUIRES: a benchmark has exited its benchmarking loop.
666 // Number of threads concurrently executing the benchmark.
774 // Benchmark registration object. The BENCHMARK() macro expands
775 // into an internal::Benchmark* object. Various methods can
776 // be called on this object to change the properties of the benchmark.
779 class Benchmark {
781 virtual ~Benchmark();
786 // Run this benchmark once with "x" as the extra argument passed
789 Benchmark* Arg(int64_t x);
791 // Run this benchmark with the given time unit for the generated output report
792 Benchmark* Unit(TimeUnit unit);
794 // Run this benchmark once for a number of values picked from the
797 Benchmark* Range(int64_t start, int64_t limit);
799 // Run this benchmark once for all values in the range [start..limit] with
802 Benchmark* DenseRange(int64_t start, int64_t limit, int step = 1);
804 // Run this benchmark once with "args" as the extra arguments passed
807 Benchmark* Args(const std::vector<int64_t>& args);
812 Benchmark* ArgPair(int64_t x, int64_t y) { in ArgPair()
819 // Run this benchmark once for a number of values picked from the
822 Benchmark* Ranges(const std::vector<std::pair<int64_t, int64_t> >& ranges);
825 Benchmark* ArgName(const std::string& name);
827 // Set the argument names to display in the benchmark name. If not called,
829 Benchmark* ArgNames(const std::vector<std::string>& names);
834 Benchmark* RangePair(int64_t lo1, int64_t hi1, int64_t lo2, int64_t hi2) { in RangePair()
841 // Pass this benchmark object to *func, which can customize
842 // the benchmark by calling various methods like Arg, Args,
844 Benchmark* Apply(void (*func)(Benchmark* benchmark));
848 Benchmark* RangeMultiplier(int multiplier);
850 // Set the minimum amount of time to use when running this benchmark. This
852 // REQUIRES: `t > 0` and `Iterations` has not been called on this benchmark.
853 Benchmark* MinTime(double t);
855 // Specify the amount of iterations that should be run by this benchmark.
856 // REQUIRES: 'n > 0' and `MinTime` has not been called on this benchmark.
859 // needed and never to control or limit how long a benchmark runs, where
861 Benchmark* Iterations(size_t n);
863 // Specify the amount of times to repeat this benchmark. This option overrides
866 Benchmark* Repetitions(int n);
868 // Specify if each repetition of the benchmark should be reported separately
869 // or if only the final statistics should be reported. If the benchmark
872 Benchmark* ReportAggregatesOnly(bool value = true);
875 Benchmark* DisplayAggregatesOnly(bool value = true);
877 // If a particular benchmark is I/O bound, runs multiple threads internally or
881 // called, the cpu time used by the benchmark will be used.
882 Benchmark* UseRealTime();
884 // If a benchmark must measure time manually (e.g. if GPU execution time is
886 // measured), call this method. If called, each benchmark iteration should
891 Benchmark* UseManualTime();
893 // Set the asymptotic computational complexity for the benchmark. If called
895 Benchmark* Complexity(BigO complexity = benchmark::oAuto);
897 // Set the asymptotic computational complexity for the benchmark. If called
899 Benchmark* Complexity(BigOFunc* complexity);
901 // Add this statistics to be computed over all the values of benchmark run
902 Benchmark* ComputeStatistics(std::string name, StatisticsFunc* statistics);
904 // Support for running multiple copies of the same benchmark concurrently
908 // Run one instance of this benchmark concurrently in t threads.
909 Benchmark* Threads(int t);
913 // benchmark once for each value in T. The benchmark run for a
914 // particular value t consists of t threads running the benchmark
916 // BENCHMARK(Foo)->ThreadRange(1,16);
923 Benchmark* ThreadRange(int min_threads, int max_threads);
925 // For each value n in the range, run this benchmark once using n threads.
928 // a benchmark with 1, 4, 7 and 8 threads.
929 Benchmark* DenseThreadRange(int min_threads, int max_threads, int stride = 1);
932 Benchmark* ThreadPerCpu();
937 explicit Benchmark(const char* name);
938 Benchmark(Benchmark const&);
948 std::vector<std::string> arg_names_; // Args for all benchmark runs
949 std::vector<std::vector<int64_t> > args_; // Args for all benchmark runs
962 Benchmark& operator=(Benchmark const&);
967 // Create and register a benchmark with the specified 'name' that invokes
970 // RETURNS: A pointer to the registered benchmark.
971 internal::Benchmark* RegisterBenchmark(const char* name,
976 internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn);
985 // (ie those created using the BENCHMARK(...) macros.
986 class FunctionBenchmark : public Benchmark {
989 : Benchmark(name), func_(func) {} in FunctionBenchmark()
999 class LambdaBenchmark : public Benchmark {
1006 : Benchmark(name), lambda_(std::forward<OLambda>(lam)) {} in LambdaBenchmark()
1012 friend Benchmark* ::benchmark::RegisterBenchmark(const char*, Lam&&);
1020 inline internal::Benchmark* RegisterBenchmark(const char* name, in RegisterBenchmark()
1028 internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn) { in RegisterBenchmark()
1039 internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn, in RegisterBenchmark()
1041 return benchmark::RegisterBenchmark( in RegisterBenchmark()
1042 name, [=](benchmark::State& st) { fn(st, args...); }); in RegisterBenchmark()
1049 class Fixture : public internal::Benchmark {
1051 Fixture() : internal::Benchmark("") {} in Fixture()
1070 } // namespace benchmark
1091 static ::benchmark::internal::Benchmark* BENCHMARK_PRIVATE_NAME(n) \
1094 #define BENCHMARK(n) \ macro
1096 (::benchmark::internal::RegisterBenchmarkInternal( \
1097 new ::benchmark::internal::FunctionBenchmark(#n, n)))
1100 #define BENCHMARK_WITH_ARG(n, a) BENCHMARK(n)->Arg((a))
1101 #define BENCHMARK_WITH_ARG2(n, a1, a2) BENCHMARK(n)->Args({(a1), (a2)})
1102 #define BENCHMARK_WITH_UNIT(n, t) BENCHMARK(n)->Unit((t))
1103 #define BENCHMARK_RANGE(n, lo, hi) BENCHMARK(n)->Range((lo), (hi))
1105 BENCHMARK(n)->RangePair({{(l1), (h1)}, {(l2), (h2)}})
1109 // Register a benchmark which invokes the function specified by `func`
1115 // void BM_takes_args(benchmark::State& state, ExtraArgs&&... extra_args) {
1118 // /* Registers a benchmark named "BM_takes_args/int_string_test` */
1122 (::benchmark::internal::RegisterBenchmarkInternal( \
1123 new ::benchmark::internal::FunctionBenchmark( \
1125 [](::benchmark::State& st) { func(st, __VA_ARGS__); })))
1129 // This will register a benchmark for a templatized function. For example:
1136 // will register BM_Foo<1> as a benchmark.
1139 (::benchmark::internal::RegisterBenchmarkInternal( \
1140 new ::benchmark::internal::FunctionBenchmark(#n "<" #a ">", n<a>)))
1144 (::benchmark::internal::RegisterBenchmarkInternal( \
1145 new ::benchmark::internal::FunctionBenchmark(#n "<" #a "," #b ">", \
1151 (::benchmark::internal::RegisterBenchmarkInternal( \
1152 new ::benchmark::internal::FunctionBenchmark( \
1166 virtual void BenchmarkCase(::benchmark::State&); \
1177 virtual void BenchmarkCase(::benchmark::State&); \
1188 virtual void BenchmarkCase(::benchmark::State&); \
1200 virtual void BenchmarkCase(::benchmark::State&); \
1233 (::benchmark::internal::RegisterBenchmarkInternal(new TestName()))
1235 // This macro will define and register a benchmark within a fixture class.
1264 ::benchmark::Initialize(&argc, argv); \
1265 if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; \
1266 ::benchmark::RunSpecifiedBenchmarks(); \
1271 // Benchmark Reporters
1273 namespace benchmark {
1305 // Interface for custom benchmark result printers.
1306 // By default, benchmark reports are printed to stdout. However an application
1315 // The number of chars in the longest benchmark name.
1346 std::string report_label; // Empty if not set by benchmark.
1397 // platform under which the benchmarks are running. The benchmark run is
1402 // Called once for each group of benchmark runs, gives information about
1403 // cpu-time and heap memory usage during the benchmark run. If the group
1408 // complexity and RMS of that benchmark family.
1445 // Simple reporter that outputs benchmark data to the console. This is the
1503 // allocation metrics for a run of the benchmark.
1549 } // namespace benchmark