Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <chrono>
- #include <functional>
- #include <utility>
- template<typename Duration = std::chrono::seconds, typename Callable, typename... Args>
- Duration measure_time(Callable&& callable, Args&&... args) {
- using namespace std::chrono;
- auto start = high_resolution_clock::now();
- std::invoke(std::forward<Callable>(callable), std::forward<Args>(args)...);
- auto stop = high_resolution_clock::now();
- return duration_cast<Duration>(stop - start);
- }
Add Comment
Please, Sign In to add comment