Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <chrono>
- #include <thread>
- using namespace std::chrono_literals;
- void testerFunction(void (foo(void))) {
- auto start = std::chrono::high_resolution_clock::now();
- foo();
- auto end = std::chrono::high_resolution_clock::now();
- std::chrono::duration<double, std::milli> elapsed = end-start;
- std::cout << "Time taken: " << std::setprecision(16) << elapsed.count() << " s\n";
- }
- // Some function
- void f() {
- std::this_thread::sleep_for(2s);
- }
- int main() {
- testerFunction(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement