MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Benchmark

Function Benchmark

tensorflow/compiler/aot/benchmark.cc:112–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void Benchmark(const Options& options, const BenchmarkFn& fn, Stats* stats) {
113 // If neither max_seconds or max_iters is set, stop at kDefaultMicros.
114 const int64 max_us = (options.max_micros <= 0 && options.max_iters <= 0)
115 ? Options::kDefaultMicros
116 : options.max_micros;
117 printf("Running benchmark for %lld us\n", max_us);
118 const int64 start_us = NowMicros();
119 int64 iters = 0;
120 while (true) {
121 const int64 iter_start_us = NowMicros();
122 fn();
123 const int64 end_us = NowMicros();
124 // Collect stats and decide whether to stop.
125 stats->per_iter_us.push_back(end_us - iter_start_us);
126 const int64 total_us = end_us - start_us;
127 ++iters;
128 if ((max_us > 0 && total_us >= max_us) ||
129 (options.max_iters > 0 && iters >= options.max_iters)) {
130 stats->total_us = total_us;
131 break;
132 }
133 }
134}
135
136} // namespace benchmark
137} // namespace tfcompile

Callers 1

TESTFunction · 0.70

Calls 3

NowMicrosFunction · 0.70
fnFunction · 0.50
push_backMethod · 0.45

Tested by 1

TESTFunction · 0.56