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 | # |
Bence Szépkúti | 44bfbe3 | 2020-08-19 16:54:51 +0200 | [diff] [blame] | 5 | # Copyright The Mbed TLS Contributors |
Bence Szépkúti | 4e9f712 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 6 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 7 | # |
| 8 | # This file is provided under the Apache License 2.0, or the |
| 9 | # GNU General Public License v2.0 or later. |
| 10 | # |
| 11 | # ********** |
| 12 | # Apache License 2.0: |
Bence Szépkúti | 09b4f19 | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 13 | # |
| 14 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 15 | # not use this file except in compliance with the License. |
| 16 | # You may obtain a copy of the License at |
| 17 | # |
| 18 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 19 | # |
| 20 | # Unless required by applicable law or agreed to in writing, software |
| 21 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 22 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 23 | # See the License for the specific language governing permissions and |
| 24 | # limitations under the License. |
Bence Szépkúti | b7246ad | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 25 | # |
Bence Szépkúti | 4e9f712 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 26 | # ********** |
| 27 | # |
| 28 | # ********** |
| 29 | # GNU General Public License v2.0 or later: |
| 30 | # |
| 31 | # This program is free software; you can redistribute it and/or modify |
| 32 | # it under the terms of the GNU General Public License as published by |
| 33 | # the Free Software Foundation; either version 2 of the License, or |
| 34 | # (at your option) any later version. |
| 35 | # |
| 36 | # This program is distributed in the hope that it will be useful, |
| 37 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 38 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 39 | # GNU General Public License for more details. |
| 40 | # |
| 41 | # You should have received a copy of the GNU General Public License along |
| 42 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 43 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 44 | # |
| 45 | # ********** |
Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 46 | |
| 47 | use warnings; |
| 48 | use strict; |
| 49 | |
| 50 | use utf8; |
| 51 | use open qw(:std utf8); |
| 52 | |
| 53 | die unless @ARGV == 1; |
| 54 | |
| 55 | my @snaps; |
| 56 | open my $fh, '<', $ARGV[0] or die; |
| 57 | { local $/ = 'snapshot='; @snaps = <$fh>; } |
| 58 | close $fh or die; |
| 59 | |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 60 | 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] | 61 | for (@snaps) |
| 62 | { |
| 63 | my ($heap, $heap_extra, $stack) = m{ |
| 64 | mem_heap_B=(\d+)\n |
| 65 | mem_heap_extra_B=(\d+)\n |
| 66 | mem_stacks_B=(\d+) |
| 67 | }xm; |
| 68 | next unless defined $heap; |
| 69 | my $total = $heap + $heap_extra + $stack; |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 70 | if( $total > $max ) { |
| 71 | ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack); |
| 72 | } |
Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 73 | } |
| 74 | |
Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 75 | printf "$max (heap $max_heap+$max_he, stack $max_stack)\n"; |