fbrosson | 3a74571 | 2018-04-04 22:26:56 +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 |
Bence Szépkúti | b7246ad | 2020-05-26 00:33:31 +0200 | [diff] [blame^] | 4 | # |
| 5 | # Copyright (C) 2014, Arm Limited, All Rights Reserved |
| 6 | # |
| 7 | # This file is part of Mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 8 | |
| 9 | use warnings; |
| 10 | use strict; |
| 11 | |
| 12 | use utf8; |
| 13 | use open qw(:std utf8); |
| 14 | |
| 15 | die unless @ARGV == 1; |
| 16 | |
| 17 | my @snaps; |
| 18 | open my $fh, '<', $ARGV[0] or die; |
| 19 | { local $/ = 'snapshot='; @snaps = <$fh>; } |
| 20 | close $fh or die; |
| 21 | |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 22 | 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] | 23 | for (@snaps) |
| 24 | { |
| 25 | my ($heap, $heap_extra, $stack) = m{ |
| 26 | mem_heap_B=(\d+)\n |
| 27 | mem_heap_extra_B=(\d+)\n |
| 28 | mem_stacks_B=(\d+) |
| 29 | }xm; |
| 30 | next unless defined $heap; |
| 31 | my $total = $heap + $heap_extra + $stack; |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 32 | if( $total > $max ) { |
| 33 | ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack); |
| 34 | } |
Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 35 | } |
| 36 | |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 37 | printf "$max (heap $max_heap+$max_he, stack $max_stack)\n"; |