Test2:...racker(3pm)
π NAME π
ok so bestie, this is Test2::Harness::Auditor::TimeTracker β the module that keeps track of your timing data while an event stream is getting processed. β±οΈβ¨ (yeah, the file is Test2:...racker when your terminal is being shy about long names, she's just built different π
)
π¦ DESCRIPTION π¦
The timetracker module tracks the timing data of an event stream, fr fr. Every event for a given job should be run through a timetracker, and then it can spill the tea on how long your test took in each of several stages. πΈ
startupβ Time from launch to first test event.eventsβ Time spent generating test events.cleanupβ Time from last test event to test exit.totalβ Total time.
it's giving full breakdown, no notes. π
β¨ SYNOPSIS β¨
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
like. look at her go. πβοΈπ¨
π METHODS π
π $tracker->process($event, $facet_data, $assert_count)
π $tracker->process($event, undef, $assert_count)
TimeTracker builds her whole state from multiple events, so every single event needs to get processed by this method. one by one bestie, she's thorough. π
the second argument is optional β if you don't hand over a facet_data, she'll just pull the facet_data from the event herself. it's mainly a lil micro-optimization so you don't call the facet_data() method on the event a million times when you already called it. we love a girl who avoids redundant work. π«Ά
π $bool = $tracker->useful()
Returns true if there's any useful data to display. if she's got nothing to show you, she'll say so. iconic honesty. β¨
π $totals = $tracker->totals()
Returns the totals, like this:
{
# Raw numbers
startup => ...,
events => ...,
cleanup => ...,
total => ...,
# Human friendly versions
h_startup => ...,
h_events => ...,
h_cleanup => ...,
h_total => ...,
}
raw numbers AND the glowed-up human friendly versions?? she said serve both. π
π $source = $tracker->source()
This method returns the data from which the totals are derived:
{
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's of the events that provided the above stamps.
start_id => ...,
stop_id => ...,
first_id => ...,
last_id => ...,
complete_id => ...,
}
receipts. she keeps receipts. π§Ύπ
π $data = $tracker->data_dump
This dumps the totals and source data:
{
totals => $tracker->totals,
source => $tracker->source,
}
everything in one place, the whole vibe check. π
π $string = $tracker->summary
This produces a summary string of the totals data:
Startup: 0.00708s | Events: 0.00000s | Cleanup: 0.10390s | Total: 0.11098s
Fields that have no data will be ommited from the string. (yes, that's how it's spelled in here, we're keeping it EXACTLY as-is bestie, no cap π«Ά)
π $table = $tracker->table
Returns this structure that is good for use in Term::Table:
{
header => ["Phase", "Time", "Raw", "Explanation"],
rows => [
['startup', $human_readible, $raw, "Time from launch to first test event."],
['events', $human_radible, $raw, 'Time spent generating test events.'],
['cleanup', $human_radible, $raw, 'Time from last test event to test exit.'],
['total', $human_radible, $raw, 'Total time.'],
],
}
look at that header. ["Phase", "Time", "Raw", "Explanation"]. a whole table?? she's so organized, main character energy fr fr. π
π @items = $tracker->job_fields()
This is used to obtain extra data to attach to the job completion event. little extras, sprinkles on top. π
π₯ SOURCE π₯
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/. go snoop bestie, it's right there. π¦
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
π AUTHORS π
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright 2020 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
and that's the whole page bestie, mwah π this was shipped as part of perl v5.40.1, dated 2026-05-10 β User Contributed Perl Documentation stays winning. periodt. π β¨
π¦ where this page comes from
- ubuntu stonking: libtest2-harness-perl 1.000172-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms