time.hpp 388 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
#ifndef MIGRAPH_GUARD_RTGLIB_TIME_HPP
#define MIGRAPH_GUARD_RTGLIB_TIME_HPP

#include <chrono>

namespace migraph {

Paul's avatar
Paul committed
8
template <class Duration, class F>
Paul's avatar
Paul committed
9
10
11
12
13
14
15
16
17
18
19
auto time(F f)
{
    auto start = std::chrono::steady_clock::now();
    f();
    auto finish = std::chrono::steady_clock::now();
    return std::chrono::duration_cast<Duration>(finish - start).count();
}

} // namespace migraph

#endif