Documentation for routine snap assembled from the following pages:

Class: Telemetry §

From Telemetry

(Telemetry) routine snap §

multi sub snap(--> Nil)
multi sub snap(Str:D $message --> Nil)
multi sub snap(Str $message = "taking heap snapshot...":$heap!)
multi sub snap(@s --> Nil)

The snap subroutine is shorthand for creating a new Telemetry object and pushing it to an array for later processing. It is exported by default. From release 2021.12, it returns the filename it's storing the snapshots in the case it's provided with a :$heap associative parameter.

use Telemetry;
my @t;
for ^5 {
    snap(@t);
    # do some stuff 
    LAST snap(@t);
}

If no array is specified, it will use an internal array for convenience.