| fbrosson | 533407a | 2018-04-04 21:44:29 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl | 
| Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 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 |  | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 18 | my ($max, $max_heap, $max_he, $max_stack) = (0, 0, 0, 0); | 
| Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 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; | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 28 | if( $total > $max ) { | 
|  | 29 | ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack); | 
|  | 30 | } | 
| Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 31 | } | 
|  | 32 |  | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 33 | printf "$max (heap $max_heap+$max_he, stack $max_stack)\n"; |