| Line | |
|---|
| 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, $max_heap, $max_he, $max_stack) = (0, 0, 0, 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 | if( $total > $max ) {
|
|---|
| 29 | ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack);
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | printf "$max (heap $max_heap+$max_he, stack $max_stack)\n";
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.