-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor
More file actions
executable file
·36 lines (32 loc) · 858 Bytes
/
Copy pathmonitor
File metadata and controls
executable file
·36 lines (32 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env perl
use v5.36;
use open ':std', ':encoding(UTF-8)';
# Finds current running program and shows Gargabe Collector statistics
my $pid = 0;
for my $process ( processes() ) {
if ( $process->{command} =~ m/raylibfs\z/ ) {
$pid = $process->{pid};
}
}
if ( $pid ) {
exec('dotnet-counters', 'monitor', '--process-id', $pid);
}
else {
warn "Error: Could not find raylibfs process!\n";
}
sub processes() {
my @ps = split /\n/, `ps a`;
shift @ps;
my @out;
for my $line ( @ps ) {
my @cols = $line =~ m/\A\s* (\S+) \s+ (\S+) \s+ (\S+) \s+ (\S+) \s+ (.*) \z/xms;
push @out, {
pid => $cols[0],
tty => $cols[1],
stat => $cols[2],
time => $cols[3],
command => $cols[4],
};
}
return wantarray ? @out : \@out;
}