Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <chrono>
- #include <string>
- using namespace std;
- using namespace chrono;
- class DurationTracker
- {
- public:
- DurationTracker( const DurationTracker& other ) // NOLINT(hicpp-use-equals-default)
- : _startTime ( other._startTime ),
- _endTime ( other._endTime ),
- _timeElapsed ( other._timeElapsed ) {}
- DurationTracker( DurationTracker&& other ) noexcept
- : _startTime ( std::move(other._startTime) ),
- _endTime ( std::move(other._endTime) ),
- _timeElapsed ( other._timeElapsed ) {}
- DurationTracker& operator=( const DurationTracker& other )
- {
- if ( this == &other )
- return *this;
- _startTime = other._startTime;
- _endTime = other._endTime;
- _timeElapsed = other._timeElapsed;
- return *this;
- }
- DurationTracker& operator=( DurationTracker&& other ) noexcept
- {
- if ( this == &other )
- return *this;
- _startTime = std::move ( other._startTime );
- _endTime = std::move ( other._endTime );
- _timeElapsed = other._timeElapsed;
- return *this;
- }
- DurationTracker ();
- ~DurationTracker ();
- void start ();
- void stop ();
- string results () const;
- double getTimeElapsed () const;
- private:
- void process ();
- high_resolution_clock::time_point _startTime;
- high_resolution_clock::time_point _endTime;
- double _timeElapsed;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement