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 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