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 |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 4 | # |
| 5 | # Copyright (C) 2014, Arm Limited, All Rights Reserved |
Bence Szépkúti | 51b41d5 | 2020-05-26 01:54:15 +0200 | [diff] [blame^] | 6 | # SPDX-License-Identifier: Apache-2.0 |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 19 | # |
| 20 | # 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] | 21 | |
| 22 | use warnings; |
| 23 | use strict; |
| 24 | |
| 25 | use utf8; |
| 26 | use open qw(:std utf8); |
| 27 | |
| 28 | die unless @ARGV == 1; |
| 29 | |
| 30 | my @snaps; |
| 31 | open my $fh, '<', $ARGV[0] or die; |
| 32 | { local $/ = 'snapshot='; @snaps = <$fh>; } |
| 33 | close $fh or die; |
| 34 | |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 35 | 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] | 36 | for (@snaps) |
| 37 | { |
| 38 | my ($heap, $heap_extra, $stack) = m{ |
| 39 | mem_heap_B=(\d+)\n |
| 40 | mem_heap_extra_B=(\d+)\n |
| 41 | mem_stacks_B=(\d+) |
| 42 | }xm; |
| 43 | next unless defined $heap; |
| 44 | my $total = $heap + $heap_extra + $stack; |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 45 | if( $total > $max ) { |
| 46 | ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack); |
| 47 | } |
Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 50 | printf "$max (heap $max_heap+$max_he, stack $max_stack)\n"; |