Skip to content
Permalink
Browse files

telemetry: allow heap => filename

:heap will autogenerate a filename. heap => "foo" will
save to "foo" unless it already exists, in which case
the PID and snapshot index are appended to the name.
heap => "foo".IO will overwrite "foo" if it exists.
:!heap will act as if :$heap were not passed at all.
  • Loading branch information...
timo committed Apr 22, 2019
1 parent 7af60ce commit 0c80e0676f06ff8bc679a058de3e24e534427b16
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/Telemetry.pm6
@@ -712,7 +712,22 @@ multi sub snap(Str:D $message --> Nil) {
}
my $snapshot-idx = 1;
multi sub snap(Str $message = "taking heap snapshot...", :$heap! --> Nil) {
my $filename = "heapsnapshot$($*PID)-$($snapshot-idx++).mvmheap";
my $filename =
$heap eqv True
?? "heapsnapshot-$($*PID)-$($snapshot-idx++).mvmheap"
!! $heap ~~ Str:D
?? $heap.IO.e
?? "$heap-$($*PID)-$($snapshot-idx++).mvmheap"
!! $heap
!! $heap ~~ IO::Path:D
?? $heap.absolute
!! $heap eqv False
?? do { $message eq "taking heap snapshot..."
?? snap()
!! snap($message);
return }
!! die "heap argument to snap must be a Bool, Str, or IO::Path, not a $heap.WHAT()";

my \T1 := Telemetry.new;
T1.message = $message with $message;
$snaps.push(T1);

0 comments on commit 0c80e06

Please sign in to comment.
You can’t perform that action at this time.