Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- #include <vector>
- using namespace std;
- class Timer
- {
- public:
- Timer() : seconds(0) {}
- ~Timer() {}
- void start() { s = std::chrono::system_clock::now(); }
- void stop()
- {
- e = std::chrono::system_clock::now();
- std::chrono::duration<double> diff = (e - s);
- seconds = diff.count();
- }
- double elapsedSeconds() { return seconds; }
- private:
- std::chrono::time_point<std::chrono::system_clock> s, e;
- double seconds;
- };
- int main(void)
- {
- Timer timer;
- timer.start();
- timer.stop();
- cout << timer.elapsedSeconds() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement