crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Timer::StartStop Class Reference

A simple start/stop watch. More...

#include <StartStop.hpp>

Construction

 StartStop ()
 Constructor initializing the values. More...
 

Control functions

void start ()
 Starts the timer. More...
 
void stop ()
 Stops the timer. More...
 
void reset ()
 Resets the timer. More...
 

Getter

std::string totalStr ()
 Gets the total duration as formatted string. More...
 

Reset

void clear ()
 Resets the internal state of the timer. More...
 

Internal state

std::chrono::steady_clock::time_point timePoint
 (Time) point of start. More...
 
std::chrono::steady_clock::duration duration
 Duration of previous runs. More...
 

Detailed Description

A simple start/stop watch.

Accumulates the number of passed milliseconds while running.

Note
This timer needs to be started manually.

Constructor & Destructor Documentation

◆ StartStop()

crawlservpp::Timer::StartStop::StartStop ( )
inline

Constructor initializing the values.

Note
Other than Timer::Simple and Timer::SimpleHR, this timer will not be started automatically on creation.
See also
start

Member Function Documentation

◆ clear()

void crawlservpp::Timer::StartStop::clear ( )
inline

Resets the internal state of the timer.

References duration, and timePoint.

◆ reset()

void crawlservpp::Timer::StartStop::reset ( )
inline

Resets the timer.

Warning
The number of milliseconds stored internally will be lost.

References duration, and timePoint.

◆ start()

void crawlservpp::Timer::StartStop::start ( )
inline

Starts the timer.

Milliseconds will be accumulated starting from now on.

If the timer is already running, it will first be stopped, i.e. the number of milliseconds stored internally will be refreshed.

See also
stop

References crawlservpp::Helper::DateTime::now(), stop(), and timePoint.

Referenced by crawlservpp::Module::Crawler::Thread::onReset(), and crawlservpp::Module::Crawler::Thread::onTick().

◆ stop()

void crawlservpp::Timer::StartStop::stop ( )
inline

Stops the timer.

The number of milliseconds stored internally will be refreshed

See also
start

References duration, crawlservpp::Helper::DateTime::now(), and timePoint.

Referenced by crawlservpp::Module::Crawler::Thread::onReset(), start(), and totalStr().

◆ totalStr()

std::string crawlservpp::Timer::StartStop::totalStr ( )
inline

Gets the total duration as formatted string.

If the timer is currenty running, it will first be stopped, i.e. the number of milliseconds passed will be refreshed.

Returns
The number of milliseconds stored internally, formatted as string.
See also
Helper::DateTime::millisecondsToString

References duration, crawlservpp::Helper::DateTime::millisecondsToString(), stop(), and timePoint.

Referenced by crawlservpp::Module::Crawler::Thread::onReset().

Member Data Documentation

◆ duration

std::chrono::steady_clock::duration crawlservpp::Timer::StartStop::duration
protected

Duration of previous runs.

Equals std::chrono::steady_clock::duration::zero() if no time has been measured yet (excluding the current run).

Referenced by clear(), reset(), stop(), and totalStr().

◆ timePoint

std::chrono::steady_clock::time_point crawlservpp::Timer::StartStop::timePoint
protected

(Time) point of start.

Equals std::chrono::steady_clock::time_point::min() if the timer has not been started yet or is currently stopped.

Referenced by clear(), reset(), start(), stop(), and totalStr().


The documentation for this class was generated from the following file: