summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/TAP/Formatter/Session.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/TAP/Formatter/Session.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/TAP/Formatter/Session.pm38
1 files changed, 36 insertions, 2 deletions
diff --git a/Master/tlpkg/tlperl/lib/TAP/Formatter/Session.pm b/Master/tlpkg/tlperl/lib/TAP/Formatter/Session.pm
index 120b4953c36..089c1e6729d 100644
--- a/Master/tlpkg/tlperl/lib/TAP/Formatter/Session.pm
+++ b/Master/tlpkg/tlperl/lib/TAP/Formatter/Session.pm
@@ -23,11 +23,11 @@ TAP::Formatter::Session - Abstract base class for harness output delegate
=head1 VERSION
-Version 3.30
+Version 3.35
=cut
-our $VERSION = '3.30';
+our $VERSION = '3.35';
=head1 METHODS
@@ -99,6 +99,11 @@ Called to close a test session.
Called by C<close_test> to clear the line showing test progress, or the parallel
test ruler, prior to printing the final test result.
+=head3 C<time_report>
+
+Return a formatted string about the elapsed (wall-clock) time
+and about the consumed CPU time.
+
=cut
sub header { }
@@ -183,4 +188,33 @@ sub _make_ok_line {
return "ok$suffix\n";
}
+sub time_report {
+ my ( $self, $formatter, $parser ) = @_;
+
+ my @time_report;
+ if ( $formatter->timer ) {
+ my $start_time = $parser->start_time;
+ my $end_time = $parser->end_time;
+ if ( defined $start_time and defined $end_time ) {
+ my $elapsed = $end_time - $start_time;
+ push @time_report,
+ $self->time_is_hires
+ ? sprintf( ' %8d ms', $elapsed * 1000 )
+ : sprintf( ' %8s s', $elapsed || '<1' );
+ }
+ my $start_times = $parser->start_times();
+ my $end_times = $parser->end_times();
+ my $usr = $end_times->[0] - $start_times->[0];
+ my $sys = $end_times->[1] - $start_times->[1];
+ my $cusr = $end_times->[2] - $start_times->[2];
+ my $csys = $end_times->[3] - $start_times->[3];
+ push @time_report,
+ sprintf('(%5.2f usr %5.2f sys + %5.2f cusr %5.2f csys = %5.2f CPU)',
+ $usr, $sys, $cusr, $csys,
+ $usr + $sys + $cusr + $csys);
+ }
+
+ return "@time_report";
+}
+
1;