Skip to content

Commit

Permalink
print average duration for caffe2 benchmark
Browse files Browse the repository at this point in the history
Summary: print average duration for caffe2 benchmark

Test Plan:
buck run //xplat/caffe2:caffe2_benchmarkAppleMac -- --init_net ~/track_init_net.pb --net ~/track_predict_net.pb --warmup 10 --input 'data' --input_dims '1,4,128,256' --input_type float --iter 20
Using additional configuration options from .buckconfig.local
Building: finished in 0.6 sec (100%) 247/2137 jobs, 0 updated
  Total time: 0.6 sec
Average Duration: 18111 us

Reviewed By: larryliu0820

Differential Revision: D27745416

fbshipit-source-id: a5d20b8ef0ba4a9547d396738d5ddd1aca57684d
  • Loading branch information
linbinyu authored and facebook-github-bot committed Apr 13, 2021
1 parent d1fac54 commit 6dd1978
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions binaries/benchmark_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,18 @@ void runNetwork(
iter,
".");
LOG(INFO) << "net runs.";
long long duration_sum = 0;
for (int i = 0; i < iter; ++i) {
caffe2::ObserverConfig::initSampleRate(1, 1, 1, 0, warmup);
fillInputBlob(workspace, tensor_protos_map, i);
if (wipe_cache) {
caffe2::wipe_cache();
}
auto start = std::chrono::high_resolution_clock::now();
CAFFE_ENFORCE(net->Run(), "Main run ", i, " has failed.");
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
duration_sum += duration.count();
// Write the output for the first num_blobs times
writeOutput(
workspace,
Expand All @@ -305,6 +310,7 @@ void runNetwork(
std::chrono::seconds(sleep_between_iteration));
}
}
std::cout << "Average Duration: " << (duration_sum/iter) << " us" << std::endl;
if (run_individual) {
LOG(INFO) << "operator runs.";
if (sleep_between_net_and_operator > 0) {
Expand Down

0 comments on commit 6dd1978

Please sign in to comment.