TAP::Formatter::Elapsed - Display time taken for each test
This document describes version 0.02 of TAP::Formatter::Elapsed
TAP::Formatter::Elapsed
prove --formatter TAP::Formatter::Elapsed -v ...
The TAP::Formatter::Elapsed module will, when used as the formatter for the prove command, add a time stamp to each test result line. While prove's --timer option is useful for displaying the time taken for an individual test file, this module can be useful to determine how long an individual test takes to run.
prove
--timer
Given the test file example.t:
example.t
#!perl -Tw use strict; use Test::More 0.88; ok sleep 2; ok sleep 2; ok sleep 2, 'last one'; done_testing;
In the default case, each test line will have appended to it the current time, the cumulative time taken so far, and the time since the last test result.
$ prove --formatter TAP::Formatter::Elapsed -v example.t example.t .. ok 1 [2012-08-17T05:41:00, 2.04, 2.04 elapsed] ok 2 [2012-08-17T05:41:02, 4.04, 2.00 elapsed] ok 3 - last one [2012-08-17T05:41:04, 6.04, 2.00 elapsed] 1..3 ok All tests successful. Files=1, Tests=3, 6 wallclock secs ( 0.02 usr 0.01 sys + 0.01 cusr 0.00 csys = 0.04 CPU) Result: PASS
The time stamp format can be customized by setting the TAP_ELAPSED_FORMAT environment variable. In addition to all of the formats provided by the strftime() function, %t0 will be replaced with the cumulative time since the beginning of the test file, and %t1 will be replaced with the time since the last test result.
TAP_ELAPSED_FORMAT
%t0
%t1
$ TAP_ELAPSED_FORMAT='%t1 %t0' prove --formatter TAP::Formatter::Elapsed -v example.t example.t .. ok 1 2.04 2.04 ok 2 2.00 4.04 ok 3 - last one 2.00 6.04 1..3 ok All tests successful. Files=1, Tests=3, 6 wallclock secs ( 0.02 usr 0.00 sys + 0.01 cusr 0.00 csys = 0.03 CPU) Result: PASS
Setting this environment variable controls the format used by TAP::Formatter::Elapsed when appending a time stamp to a test result. The default value is [%Y-%m-%dT%H:%M:%S, %t0, %t1 elapsed]. The formats %t0 and %t1 are replaced with the cumulative time and the time since the last test result, respectively. A single space is always prefixed to the time stamp, to separate it from the test result.
[%Y-%m-%dT%H:%M:%S, %t0, %t1 elapsed]
Chris Grau mailto:cgrau@cpan.org
Copyright (c) 2012, Chris Grau.
To install TAP::Formatter::Elapsed, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TAP::Formatter::Elapsed
CPAN shell
perl -MCPAN -e shell install TAP::Formatter::Elapsed
For more information on module installation, please visit the detailed CPAN module installation guide.