Go to the documentation of this file.
11 #include "util/benchmark.h"
12 #include "util/flags.h"
16 #define snprintf _snprintf
24 void Benchmark::Register() {
31 return std::chrono::duration_cast<std::chrono::nanoseconds>(
63 b->func()(iters,
arg);
81 while (
ns < (
int)1e9 && iters < (
int)1e9) {
83 if (
ns / iters == 0) {
86 iters = (
int)1e9 /
static_cast<int>(
ns / iters);
98 snprintf(mb,
sizeof mb,
"\t%7.2f MB/s",
99 ((
double)
bytes / 1e6) / ((
double)
ns / 1e9));
101 if (
arg >= (1 << 20)) {
102 snprintf(suf,
sizeof suf,
"/%dM",
arg / (1 << 20));
103 }
else if (
arg >= (1 << 10)) {
104 snprintf(suf,
sizeof suf,
"/%dK",
arg / (1 << 10));
106 snprintf(suf,
sizeof suf,
"/%d",
arg);
109 printf(
"%s%s\t%8d\t%10lld ns/op%s\n",
b->name(), suf, iters,
110 (
long long)
ns / iters, mb);
115 if (argc == 1)
return true;
116 for (
int i = 1;
i < argc;
i++) {
117 if (RE2::PartialMatch(
name, argv[
i]))
123 int main(
int argc,
const char** argv) {
void SetBenchmarkBytesProcessed(int64_t b)
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
void StopBenchmarkTiming()
static bool WantBench(const char *name, int argc, const char **argv)
static void RunFunc(Benchmark *b, int iters, int arg)
void SetBenchmarkItemsProcessed(int64_t i)
int main(int argc, const char **argv)
def Benchmark(outbase, bench_cpu=True, runs=12, fasttable=False)
void StartBenchmarkTiming()
static void RunBench(Benchmark *b, int arg)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:46