-
-
28 May 2019 09:10:06 UTC
- Distribution: Log-Timer
- Module version: 1.0.1
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository (git clone)
- Issues
- Testers (306 / 0 / 5)
- Kwalitee
Bus factor: 1- 94.37% Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (12.36KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Log::Timer - track nested timing information
VERSION
version 1.0.1
SYNOPSIS
use Log::Timer; sub some_action { my $sub_timer = subroutine_timer(); # do things ... }
FUNCTIONS
timer
my $timer1 = timer('GET /foo'); my $timer2 = timer('update_all_things'); my $timer3 = timer('fetching data from DB', { prefix => $request_url, context => $request_id, });
Start a timer. When the returned object gets destroyed, logs the time elapsed (at
trace
level).All timers with the same
$message
contribute to a set of stats, seereport_timing_stats
The
prefix
is just added in front of the log message.Timers started "inside" other timers will get logged indented, so that you can see the breakdown of any outer timings. If you need to capture several timer metrics at the same level, you can pass
indent_increase => 0
after the first timer.If you're running a set of asynchronous tasks, using the same
context
for each logical task (using for example a request id) will ensure that the nested indenting makes sense.subroutine_timer
my $timer1 = subroutine_timer(); my $timer2 = subroutine_timer($message, { prefix => $request_url, context => $request_id, depth => 2, });
Same as "
timer
", but the$message
is automatically prefixed with the name of the current subroutine. You can pass adepth
option (defaults to 1) to pick a sub further up the call stack.report_timing_stats
Log::Timer::report_timing_stats();
Logs (at
info
level) some statistical information about the timers ran until now, grouped by message. Then clears the stored values.This is also called automatically at
END
time.clear_timing_stats
Log::Timer::clear_timing_stats();
Clears all values stored for statistical purposes.
AUTHORS
Johan Lindstrom <Johan.Lindstrom@broadbean.com>
Gianni Ceccarelli <gianni.ceccarelli@broadbean.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2019 by BroadBean UK, a CareerBuilder Company.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Log::Timer, copy and paste the appropriate command in to your terminal.
cpanm Log::Timer
perl -MCPAN -e shell install Log::Timer
For more information on module installation, please visit the detailed CPAN module installation guide.