LibreOffice Module vcl (master) 1
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TaskStopwatch Class Reference

Helper class primary used to track time of long running iterating tasks. More...

#include <TaskStopwatch.hxx>

Public Member Functions

 TaskStopwatch (bool bConciderLastIterTime=true)
 Per default the watch considers the last iter time when asking for an other iteration, so considers Scheduler::acceptableTaskTime as a maximum value. More...
 
bool continueIter ()
 Returns true, if another iteration will probably pass in the time slot. More...
 
void reset ()
 Reset the stopwatch. More...
 
void setInputStop (VclInputFlags eInputStop=eDefaultInputStop)
 Sets the input events, which should also "exceed" the stopwatch. More...
 
VclInputFlags inputStop () const
 

Static Public Member Functions

static unsigned int timeSlice ()
 Sets the time considered the acceptable maximum for a task to run. More...
 
static void setTimeSlice (unsigned int nTimeSlice)
 

Private Member Functions

bool nextIter ()
 

Private Attributes

sal_uInt64 m_nStartTicks
 
sal_uInt64 m_nIterStartTicks
 
bool m_bConsiderLastIterTime
 
VclInputFlags m_eInputStop
 

Static Private Attributes

static constexpr VclInputFlags eDefaultInputStop = VCL_INPUT_ANY & ~VclInputFlags::TIMER
 
static constexpr unsigned int nDefaultTimeSlice = 50
 
static unsigned int m_nTimeSlice = TaskStopwatch::nDefaultTimeSlice
 

Detailed Description

Helper class primary used to track time of long running iterating tasks.

Normally it should be sufficient to instantiate the watch object before starting the iteration and query continueIter() at the end of each.

Called Stopwatch, because there is already a Timer class in the Scheduler.

TODO: merge into the general Scheduler, so this can also be used to track Task runtimes in a more general way. TODO: handle fast iterations, where continueIter is called multiple times per tick, by counting the iterations per tick and use that for approximation.

Definition at line 31 of file TaskStopwatch.hxx.

Constructor & Destructor Documentation

◆ TaskStopwatch()

TaskStopwatch::TaskStopwatch ( bool  bConciderLastIterTime = true)
inline

Per default the watch considers the last iter time when asking for an other iteration, so considers Scheduler::acceptableTaskTime as a maximum value.

If you already know your iter time vary in a large range, consider setting bConciderLastIterTime to false, so Scheduler::acceptableTaskTime will be used as a minimum time slot.

Definition at line 75 of file TaskStopwatch.hxx.

References Time.

Member Function Documentation

◆ continueIter()

bool TaskStopwatch::continueIter ( )
inline

Returns true, if another iteration will probably pass in the time slot.

Definition at line 86 of file TaskStopwatch.hxx.

◆ inputStop()

VclInputFlags TaskStopwatch::inputStop ( ) const
inline

Definition at line 103 of file TaskStopwatch.hxx.

◆ nextIter()

bool TaskStopwatch::nextIter ( )
inlineprivate

Definition at line 42 of file TaskStopwatch.hxx.

References Application::AnyInput(), and tools::Time::GetSystemTicks().

◆ reset()

void TaskStopwatch::reset ( )
inline

Reset the stopwatch.

Definition at line 91 of file TaskStopwatch.hxx.

References tools::Time::GetSystemTicks().

◆ setInputStop()

void TaskStopwatch::setInputStop ( VclInputFlags  eInputStop = eDefaultInputStop)
inline

Sets the input events, which should also "exceed" the stopwatch.

Per default this ignores the VclInputFlags::TIMER.

Definition at line 102 of file TaskStopwatch.hxx.

◆ setTimeSlice()

static void TaskStopwatch::setTimeSlice ( unsigned int  nTimeSlice)
inlinestatic

Definition at line 112 of file TaskStopwatch.hxx.

◆ timeSlice()

static unsigned int TaskStopwatch::timeSlice ( )
inlinestatic

Sets the time considered the acceptable maximum for a task to run.

This is an orientation for long time background jobs to yield to the scheduler, so Idle task don't starve each other too much.

Definition at line 111 of file TaskStopwatch.hxx.

Member Data Documentation

◆ eDefaultInputStop

constexpr VclInputFlags TaskStopwatch::eDefaultInputStop = VCL_INPUT_ANY & ~VclInputFlags::TIMER
staticconstexprprivate

Definition at line 33 of file TaskStopwatch.hxx.

◆ m_bConsiderLastIterTime

bool TaskStopwatch::m_bConsiderLastIterTime
private

Definition at line 39 of file TaskStopwatch.hxx.

◆ m_eInputStop

VclInputFlags TaskStopwatch::m_eInputStop
private

Definition at line 40 of file TaskStopwatch.hxx.

◆ m_nIterStartTicks

sal_uInt64 TaskStopwatch::m_nIterStartTicks
private

Definition at line 38 of file TaskStopwatch.hxx.

◆ m_nStartTicks

sal_uInt64 TaskStopwatch::m_nStartTicks
private

Definition at line 37 of file TaskStopwatch.hxx.

◆ m_nTimeSlice

unsigned int TaskStopwatch::m_nTimeSlice = TaskStopwatch::nDefaultTimeSlice
staticprivate

Definition at line 35 of file TaskStopwatch.hxx.

◆ nDefaultTimeSlice

constexpr unsigned int TaskStopwatch::nDefaultTimeSlice = 50
staticconstexprprivate

Definition at line 34 of file TaskStopwatch.hxx.


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