1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
9 namespace MKLDNNPlugin {
15 std::chrono::high_resolution_clock::time_point __start;
16 std::chrono::high_resolution_clock::time_point __finish;
19 PerfCount(): duration(0), num(0) {}
21 uint64_t avg() { return (num == 0) ? 0 : duration / num; }
25 __start = std::chrono::high_resolution_clock::now();
29 __finish = std::chrono::high_resolution_clock::now();
31 duration += std::chrono::duration_cast<std::chrono::microseconds>(__finish - __start).count();
35 friend class PerfHelper;
42 explicit PerfHelper(PerfCount &count): counter(count) { counter.start_itr(); }
44 ~PerfHelper() { counter.finish_itr(); }
47 } // namespace MKLDNNPlugin
49 #define PERF(_counter) PerfHelper __helper##__counter (_counter->PerfCounter());