The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Time::Checkpoint

ABSTRACT

Simple module to report deltas between waypoints in code, with extensible reactions.

SYNOPSIS

  my $t = Time::Checkpoint->new( );
  $t->checkpoint( 'Start' );

  # Code elapses ...

  my $delta = $t->checkpoint( 'Start' );

  # With callback

  my $t = Time::Checkpoint->new(
    callback => \&print_delta
  );

  $t->checkpoint( 'foo' );

  sub print_delta {
    my ($checkpoint, $old_time, $new_time) = (@_);
    my $delta = $new_time - $old_time;
    $LOG->debug( "$checkpoint: delta $delta seconds" );
  }

  # More code elapses...

  $t->checkpoint( 'foo' ); # print_delta is called

METHODS

Constructor

new( )

    The constructor takes either no arguments or a hash with one key: callback. If a callback is passed (a code ref), that code will be called with the arguments $name_of_checkpoint, $old_timestamp, $new_timestamp. Returns a Time::Checkpoint object.

checkpoint( $name )
cp( $name )

    Takes one argument, the name of the checkpoint reached. When called, it will perform a hash lookup to determine when it was called last. It will return the delta between the two. It will also call the 'callback' code, as mentioned above, provided it exists.

list_checkpoints( )
lscp( )

    Takes no arguments. Returns a hash of checkpoints and their timestamps.

checkpoint_status( $name )
cpstat( $name )

    Returns the timestamp for a given checkpoint, or undef.

checkpoint_remove( $name )
cprm( $name )

    Removes the specified checkpoint, returning its value if it had one.

flush( )

    Removes all checkpoints.

AUTHOR

  Jane A. Avriette <jane@cpan.org>

BUGS

Yep.

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 168:

You forgot a '=back' before '=head2'

Around line 170:

'=item' outside of any '=over'

Around line 230:

You forgot a '=back' before '=head1'