1Test2::Harness::AuditorU:s:eTrimCeoTnrtarcikbeurt(e3d)PTeerslt2D:o:cHuamrennetsast:i:oAnuditor::TimeTracker(3)
2
3
4

NAME

6       Test2::Harness::Auditor::TimeTracker - Module that tracks timing data
7       while an event stream is processed.
8

DESCRIPTION

10       The timetracker module tracks timing data of an event stream. All
11       events for a given job should be run through a timetracker, which can
12       then give data on how long the test took in each of several stages.
13
14       startup - Time from launch to first test event.
15       events - Time spent generating test events.
16       cleanup - Time from last test event to test exit.
17       total - Total time.
18

SYNOPSIS

20           use Test2::Harness::Auditor::TimeTracker;
21
22           my $tracker = Test2::Harness::Auditor::TimeTracker->new();
23
24           my $assert_count = 0;
25           for my $event (@events) {
26               my $facet_data = $events->facet_data;
27               $assert_count++ if $facet_data->{assert};
28               $tracker->process($event, $facet_data, $assert_count);
29           }
30
31           print $tracker->summary;
32           # Startup: 0.00708s | Events: 0.00000s | Cleanup: 0.10390s | Total: 0.11098s
33

METHODS

35       $tracker->process($event, $facet_data, $assert_count)
36       $tracker->process($event, undef, $assert_count)
37           TimeTracker builds its state from multiple events, each event
38           should be processed by this method.
39
40           The second argument is optional, if no facet_data is provided it
41           will pull the facet_data from the event itself. This is mainly a
42           micro-optimization to avoid calling the facet_data() method on the
43           event multiple times if you have already called it.
44
45       $bool = $tracker->useful()
46           Returns true if there is any useful data to display.
47
48       $totals = $tracker->totals()
49           Returns the totals like this:
50
51               {
52                   # Raw numbers
53                   startup => ...,
54                   events  => ...,
55                   cleanup => ...,
56                   total   => ...,
57
58                   # Human friendly versions
59                   h_startup => ...,
60                   h_events  => ...,
61                   h_cleanup => ...,
62                   h_total   => ...,
63               }
64
65       $source = $tracker->source()
66           This method returns the data from which the totals are derived.
67
68               {
69                   start => ...,    # timestamp of the job starting
70                   stop  => ...,    # timestamp of the job ending
71                   first => ...,    # timestamp of the first non-harness event
72                   last  => ...,    # timestamp of the last non-harness event
73
74                   # These are event_id's of the events that provided the above stamps.
75                   start_id    => ...,
76                   stop_id     => ...,
77                   first_id    => ...,
78                   last_id     => ...,
79                   complete_id => ...,
80               }
81
82       $data = $tracker->data_dump
83           This dumps the totals and source data:
84
85               {
86                   totals => $tracker->totals,
87                   source => $tracker->source,
88               }
89
90       $string = $tracker->summary
91           This produces a summary string of the totals data:
92
93               Startup: 0.00708s | Events: 0.00000s | Cleanup: 0.10390s | Total: 0.11098s
94
95           Fields that have no data will be ommited from the string.
96
97       $table = $tracker->table
98           Returns this structure that is good for use in Term::Table.
99
100               {
101                   header => ["Phase", "Time", "Raw", "Explanation"],
102                   rows   => [
103                       ['startup', $human_readible, $raw, "Time from launch to first test event."],
104                       ['events',  $human_radible,  $raw, 'Time spent generating test events.'],
105                       ['cleanup', $human_radible,  $raw, 'Time from last test event to test exit.'],
106                       ['total',   $human_radible,  $raw, 'Total time.'],
107                   ],
108               }
109
110       @items = $tracker->job_fields()
111           This is used to obtain extra data to attach to the job completion
112           event.
113

SOURCE

115       The source code repository for Test2-Harness can be found at
116       http://github.com/Test-More/Test2-Harness/.
117

MAINTAINERS

119       Chad Granum <exodist@cpan.org>
120

AUTHORS

122       Chad Granum <exodist@cpan.org>
123
125       Copyright 2020 Chad Granum <exodist7@gmail.com>.
126
127       This program is free software; you can redistribute it and/or modify it
128       under the same terms as Perl itself.
129
130       See http://dev.perl.org/licenses/
131
132
133
134perl v5.38.0                      2023-1T0e-s0t42::Harness::Auditor::TimeTracker(3)
Impressum