NAME
App::Timestamper - prefix lines with the timestamps of their arrivals.
VERSION
version 0.2.1
SYNOPSIS
use App::Timestamper;
App::Timestamper->new({ argv => [@ARGV] })->run();
DESCRIPTION
App::Timestamper is a pure-Perl command line program that filters the input so the timestamps (in seconds+fractions since the UNIX epoch) are prefixed to the lines based on the time of the arrival.
So if the input was something like:
First Line
Second Line
Third Line
It will become something like:
1435254285.978485482\tFirst Line
1435254302.569615087\tSecond Line
1435254319.809459781\tThird Line
Some use cases
Some people asked me what is timestamper useful for, so I'll try to explain because I wrote the first version out of a need.
Let's suppose you have a simulation that outputs a "Reached $N iterations" line after every certain number of iterations. Like so:
Reached 100000 iterations
Reached 200000 iterations
Reached 300000 iterations
.
.
.
You wish to draw a graph of iterations vs. time to analyse the performance of the program. So what you can do is pipe it through timestamper and then get:
1435254285.978485482\tReached 100000 iterations
1435254302.569615087\tReached 200000 iterations
1435254319.809459781\tReached 300000 iterations
And after putting it in a file (using "tee" or whatever), you can filter the lines like this:
perl -lane 'print "$1\t$2" if /\A([0-9\.]+)\tReached ([0-9]+) iterations\z/'
And get a nice tab-separated-value report of the time stamps in seconds and the iterations which you can plot using your favourite spreadsheet program or visualation framework.
Hope it helps.
COMMON REQUESTS
Can you add an option to provide formatting options to the timestamp?
This was requested here - https://rt.cpan.org/Public/Bug/Display.html?id=106258 - and my reply was that it may be considered unnecessary feature creep, which may also hurt performance.
Nevertheless, I implemented a separate CPAN distribution and executable to do that - see App::Timestamper::Format .
Enjoy!
I want a Pony!
Sure thing! Here you go:
$ cat | perl -pE 's#^#Fluttershy\t#' | timestamper
Arrrrrr!
Avast!
Ye scurvy dogs!
1442662118.609309912 Fluttershy Arrrrrr!
1442662118.609441042 Fluttershy Avast!
1442662118.609464884 Fluttershy Ye scurvy dogs!
(Fluttershy being http://mlp.wikia.com/wiki/Fluttershy .)
How to add a different pony is left as an exercise for the reader.
SUBROUTINES/METHODS
new
A constructor. Accepts the argv named arguments.
run
Runs the program.
SEE ALSO
“ts” from “moreutils”
“ts” is a program that is reportedely similar to “timestamper” and is contained in joeyh’s “moreutils” (see http://joeyh.name/code/moreutils/) package. It is not easy to find online.
Chumbawamba’s song “Tubthumping”
I really like the song “Tubthumping” by Chumbawamba, which was a hit during the 1990s and whose title sounds similar to “Timestamping”, so please check it out:
English Wikipedia Page
YouTube Search for the Video
http://www.youtube.com/results?search_query=chumbawamba%20tubthumping
SUPPORT
Websites
The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.
MetaCPAN
A modern, open-source CPAN search engine, useful to view POD in HTML format.
RT: CPAN's Bug Tracker
The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
https://rt.cpan.org/Public/Dist/Display.html?Name=App-Timestamper
CPANTS
The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
CPAN Testers
The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
CPAN Testers Matrix
The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
CPAN Testers Dependencies
The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
Bugs / Feature Requests
Please report any bugs or feature requests by email to bug-app-timestamper at rt.cpan.org
, or through the web interface at https://rt.cpan.org/Public/Bug/Report.html?Queue=App-Timestamper. You will be automatically notified of any progress on the request by the system.
Source Code
The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)
https://github.com/shlomif/App-Timestamper
git clone git://github.com/shlomif/App-Timestamper.git
AUTHOR
Shlomi Fish <shlomif@cpan.org>
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/shlomif/App-Timestamper/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
COPYRIGHT AND LICENSE
This software is Copyright (c) 2015 by Shlomi Fish.
This is free software, licensed under:
The MIT (X11) License