.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test2::Harness::Auditor::TimeTracker 3pm" .TH Test2::Harness::Auditor::TimeTracker 3pm "2023-03-12" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test2::Harness::Auditor::TimeTracker \- Module that tracks timing data while an event stream is processed. .SH "DESCRIPTION" .IX Header "DESCRIPTION" The timetracker module tracks timing data of an event stream. All events for a given job should be run through a timetracker, which can then give data on how long the test took in each of several stages. .IP "startup \- Time from launch to first test event." 4 .IX Item "startup - Time from launch to first test event." .PD 0 .IP "events \- Time spent generating test events." 4 .IX Item "events - Time spent generating test events." .IP "cleanup \- Time from last test event to test exit." 4 .IX Item "cleanup - Time from last test event to test exit." .IP "total \- Total time." 4 .IX Item "total - Total time." .PD .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Test2::Harness::Auditor::TimeTracker; \& \& my $tracker = Test2::Harness::Auditor::TimeTracker\->new(); \& \& my $assert_count = 0; \& for my $event (@events) { \& my $facet_data = $events\->facet_data; \& $assert_count++ if $facet_data\->{assert}; \& $tracker\->process($event, $facet_data, $assert_count); \& } \& \& print $tracker\->summary; \& # Startup: 0.00708s | Events: 0.00000s | Cleanup: 0.10390s | Total: 0.11098s .Ve .SH "METHODS" .IX Header "METHODS" .ie n .IP "$tracker\->process($event, $facet_data, $assert_count)" 4 .el .IP "\f(CW$tracker\fR\->process($event, \f(CW$facet_data\fR, \f(CW$assert_count\fR)" 4 .IX Item "$tracker->process($event, $facet_data, $assert_count)" .PD 0 .ie n .IP "$tracker\->process($event, undef, $assert_count)" 4 .el .IP "\f(CW$tracker\fR\->process($event, undef, \f(CW$assert_count\fR)" 4 .IX Item "$tracker->process($event, undef, $assert_count)" .PD TimeTracker builds its state from multiple events, each event should be processed by this method. .Sp The second argument is optional, if no facet_data is provided it will pull the facet_data from the event itself. This is mainly a micro-optimization to avoid calling the \f(CW\*(C`facet_data()\*(C'\fR method on the event multiple times if you have already called it. .ie n .IP "$bool = $tracker\->\fBuseful()\fR" 4 .el .IP "\f(CW$bool\fR = \f(CW$tracker\fR\->\fBuseful()\fR" 4 .IX Item "$bool = $tracker->useful()" Returns true if there is any useful data to display. .ie n .IP "$totals = $tracker\->\fBtotals()\fR" 4 .el .IP "\f(CW$totals\fR = \f(CW$tracker\fR\->\fBtotals()\fR" 4 .IX Item "$totals = $tracker->totals()" Returns the totals like this: .Sp .Vb 6 \& { \& # Raw numbers \& startup => ..., \& events => ..., \& cleanup => ..., \& total => ..., \& \& # Human friendly versions \& h_startup => ..., \& h_events => ..., \& h_cleanup => ..., \& h_total => ..., \& } .Ve .ie n .IP "$source = $tracker\->\fBsource()\fR" 4 .el .IP "\f(CW$source\fR = \f(CW$tracker\fR\->\fBsource()\fR" 4 .IX Item "$source = $tracker->source()" This method returns the data from which the totals are derived. .Sp .Vb 5 \& { \& start => ..., # timestamp of the job starting \& stop => ..., # timestamp of the job ending \& first => ..., # timestamp of the first non\-harness event \& last => ..., # timestamp of the last non\-harness event \& \& # These are event_id\*(Aqs of the events that provided the above stamps. \& start_id => ..., \& stop_id => ..., \& first_id => ..., \& last_id => ..., \& complete_id => ..., \& } .Ve .ie n .IP "$data = $tracker\->data_dump" 4 .el .IP "\f(CW$data\fR = \f(CW$tracker\fR\->data_dump" 4 .IX Item "$data = $tracker->data_dump" This dumps the totals and source data: .Sp .Vb 4 \& { \& totals => $tracker\->totals, \& source => $tracker\->source, \& } .Ve .ie n .IP "$string = $tracker\->summary" 4 .el .IP "\f(CW$string\fR = \f(CW$tracker\fR\->summary" 4 .IX Item "$string = $tracker->summary" This produces a summary string of the totals data: .Sp .Vb 1 \& Startup: 0.00708s | Events: 0.00000s | Cleanup: 0.10390s | Total: 0.11098s .Ve .Sp Fields that have no data will be ommited from the string. .ie n .IP "$table = $tracker\->table" 4 .el .IP "\f(CW$table\fR = \f(CW$tracker\fR\->table" 4 .IX Item "$table = $tracker->table" Returns this structure that is good for use in Term::Table. .Sp .Vb 9 \& { \& header => ["Phase", "Time", "Raw", "Explanation"], \& rows => [ \& [\*(Aqstartup\*(Aq, $human_readible, $raw, "Time from launch to first test event."], \& [\*(Aqevents\*(Aq, $human_radible, $raw, \*(AqTime spent generating test events.\*(Aq], \& [\*(Aqcleanup\*(Aq, $human_radible, $raw, \*(AqTime from last test event to test exit.\*(Aq], \& [\*(Aqtotal\*(Aq, $human_radible, $raw, \*(AqTotal time.\*(Aq], \& ], \& } .Ve .ie n .IP "@items = $tracker\->\fBjob_fields()\fR" 4 .el .IP "\f(CW@items\fR = \f(CW$tracker\fR\->\fBjob_fields()\fR" 4 .IX Item "@items = $tracker->job_fields()" This is used to obtain extra data to attach to the job completion event. .SH "SOURCE" .IX Header "SOURCE" The source code repository for Test2\-Harness can be found at \&\fIhttp://github.com/Test\-More/Test2\-Harness/\fR. .SH "MAINTAINERS" .IX Header "MAINTAINERS" .IP "Chad Granum " 4 .IX Item "Chad Granum " .SH "AUTHORS" .IX Header "AUTHORS" .PD 0 .IP "Chad Granum " 4 .IX Item "Chad Granum " .PD .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2020 Chad Granum . .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP See \fIhttp://dev.perl.org/licenses/\fR