Skip to content

Timer

Used to measure the computation time of an algorithm.

The sole purpose of the Timer class is to create a Timing object in a safe way, i.e., to ensure that the Timing object always holds a starting and finishing time.

Examples:

Basic usage:

>>> from luna_quantum import Timer
>>> timer = Timer.start()
>>> solution = ... # create a solution by running an algorithm.
>>> timing = timer.stop()

start staticmethod

start() -> Timer

Create a timer that starts counting immediately.

Returns:

Type Description
Timer

The timer.

stop

stop() -> Timing

Stop the timer, and get the resulting Timing object.

Returns:

Type Description
Timing

The timing object that holds the start and end time.