Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sysread/time-spent
Perl module for tracking time using a rolling average
https://github.com/sysread/time-spent
Last synced: about 1 month ago
JSON representation
Perl module for tracking time using a rolling average
- Host: GitHub
- URL: https://github.com/sysread/time-spent
- Owner: sysread
- Created: 2016-06-07T20:52:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-26T17:49:23.000Z (almost 7 years ago)
- Last Synced: 2023-08-20T23:11:54.634Z (over 1 year ago)
- Language: Perl
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
Awesome Lists containing this project
README
=pod
=encoding UTF-8
=head1 NAME
Time::Spent - Track events and calculate a rolling average of time, er, spent
=head1 VERSION
version 0.02
=head1 SYNOPSIS
use Time::Spent;
my $tracker = Time::Spent->new( length => 3 );
$tracker->start( 'foo' );
sleep 3;
$tracker->stop( 'foo' );
$tracker->avg; # 3 = 3/1$tracker->start( 'bar' );
sleep 1;
$tracker->stop( 'bar' );
$tracker->avg; # 2 = (3+1)/2$tracker->start( 'baz' );
sleep 5;
$tracker->stop( 'baz' );
$tracker->avg; # 3 = (3+1+5)/3;$tracker->start( 'bat' );
sleep 6;
$tracker->stop( 'bat' );
$tracker->avg; # 4 = (1+5+6)/3my $tracker = Time::Spent->new( length => 3 );
$tracker->start( 'life' );
sleep 35;
$tracker->start( 'universe' );
sleep 76;
$tracker->start( 'everything' );
sleep 15;$tracker->stop( 'life', 'universe', 'everything' );
$tracker->avg; # 42 (GET IT?!)=head1 DESCRIPTION
C uses a simple rolling average to track tasks by the amount of
time they take.=head1 METHODS
=head2 new
Create a new C object. Accepts one named parameter, C,
which must be a positive whole number specifying the number of historical
entries to use in the calculation of the rolling average.Time::Spent->new( length => 30 );
=head2 start
Begins tracking for the specified identifiers. Returns the number of new
specifiers tracked. Croaks if the identifier is already being tracked or if no
identifiers are provided.$tracker->start( 'ident1', 'ident2', 'ident3' ); # returns 3
$tracker->start( 'ident1' ); # croaks because ident1 is already tracked=head2 stop
Completes tracking for the specified identifiers. The time taken since the call
to L for each identifier is then added to the historical average time.
Removes completed entries' times from tracking as needed to maintain the
expected history length. Croaks if any provided identifier is not tracked or if
no identifiers are provided.$tracker->stop( 'ident1' ); # croaks because ident1 is not tracked
$tracker->start( 'ident1' );
$tracker->stop( 'ident1' ); # returns 1
$tracker->start( 'ident1', 'ident2', 'ident3' ); # ok because we stopped tracking ident1
$tracker->stop( 'ident1' ); # returns 1
$tracker->stop( 'ident2', 'ident3' ); # returns 2=head2 avg
Returns the average time taken for tracked identifiers.
=head2 is_tracking
Returns true if the identifier passed is currently being tracked (that is, it
has been Led but not Lped.=head1 AUTHOR
Jeff Ober
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Jeff Ober.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.=cut