Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # Parse a massif.out.xxx file and output peak total memory usage |
| 4 | |
| 5 | use warnings; |
| 6 | use strict; |
| 7 | |
| 8 | use utf8; |
| 9 | use open qw(:std utf8); |
| 10 | |
| 11 | die unless @ARGV == 1; |
| 12 | |
| 13 | my @snaps; |
| 14 | open my $fh, '<', $ARGV[0] or die; |
| 15 | { local $/ = 'snapshot='; @snaps = <$fh>; } |
| 16 | close $fh or die; |
| 17 | |
| 18 | my $max = 0; |
| 19 | for (@snaps) |
| 20 | { |
| 21 | my ($heap, $heap_extra, $stack) = m{ |
| 22 | mem_heap_B=(\d+)\n |
| 23 | mem_heap_extra_B=(\d+)\n |
| 24 | mem_stacks_B=(\d+) |
| 25 | }xm; |
| 26 | next unless defined $heap; |
| 27 | my $total = $heap + $heap_extra + $stack; |
| 28 | $max = $total if $total > $max; |
| 29 | } |
| 30 | |
| 31 | printf "$max\n"; |