stopwatch module

This module contains a class StopWatch. You can use stopwatches to conveniently measure the amount of time required by some piece of code in your program. The stopwatch will measure both, the time beginning with the moment it was created to the moment it is added to a section (full time), as well as the time of sub sections of this period (lap times).

The following code snippet visualizes how to use the StopWatch class:

watch = stopwatch.StopWatch()
for i in range(10):
    compute(i)
    watch.lap("time to calculate something with parameter n=%d" % i)

watch.addToSection(section)

In this snippet, section is an install of class vhistsection.VhistSection.

Warning: On Windows, user (children) and system (children) will always be 0.

class pyvhist.stopwatch.StopWatch

A stopwatch class. You can use stopwatches to conventiently measure the time required by a peace of code.

__init__()

Creates a new stopwatch object

lap(lapname)

Takes a lap time and starts a new lap. Lap times measure the time period starting with the last call of lap() up until the next call. If lap has not been called before, the creation of the stop watch is used as the starting time.

lapname is a string, which contains the name of the lap, i.e. 'initialization', 'iteration 1, cleanup etc.

addToSection(section)

Adds the time information to a section

section must be a VhistSection object. The stopwatch’s measurements will be added to the user-defined attributes of this workflow step.

Previous topic

tempdir module

Next topic

logger module

This Page