Xacobeo::Timer(3pm)

Xacobeo::Timer3pm

A custom made timer.

Usage

        use Xacobeo::Timer;
        
        # As a one time use
        my $timer = Xacobeo::Timer->start("Long operation");
        do_long_operation();
        $timer->elapsed(); # Displays the time elapsed
        
        # A simple stop watch (the destructor displays the time elapsed)
        my $TIMER = Xacobeo::Timer->new("Method calls");
        sub hotspot {
                $TIMER->start();
                # Very slow stuff here
                $TIMER->stop();
        }

Overview

This package provides a very simple timer. This timer is used for finding hot spots in the application.

The timer is quite simple it provides the method "start" that starts the timer and the method "stop" that stops the timer and accumulates the elapsed time. The method "show" can be used to print the time elapsed so far while the method "elapsed" returns the time elapsed so far.

When an instance of this class dies (because it was undefed or collected by the garbage collector) the builtin Perl desctrutor will automatically call the method "show". But if the method show or elapsed was called during the lifetime of the instance then the destructor will not invoke the method show.

Methods

The package defines the following methods:

new

Creates a new Timer.

Parameters:

•

$name (Optional)

The name of the timer.

start

Starts the timer. If this sub is called without a blessed instance then a new Timer will be created.

Parameters:

•

$name (optional)

The name is used only when called without a blessed instance.

stop

Stops the timer and adds accumulates the elapsed time. If the timer wasn't started previously this results in a no-op.

show

Prints the elapsed time. This method stops the timer if it was started previously and wasn't stopped.

elapsed

Returns the total time elapsed so far. If the timer was already started the pending time will not be taking into account.

Releases

4 releases since Debian 6.0 (Squeeze); the text changed 3 times.

  1. 6.0
  2. 7
  3. 8
  4. 9

Authors

Emmanuel Rodriguez <[email protected]>.

From xacobeo 0.15-3+b2 in Debian 9 (Stretch). Parsed by carta from the page's man source.