| 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 | 700ee44 | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 4 | # | 
| Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 5 | # Copyright The Mbed TLS Contributors | 
| Bence Szépkúti | c7da1fe | 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. | 
| Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 19 |  | 
|  | 20 | use warnings; | 
|  | 21 | use strict; | 
|  | 22 |  | 
|  | 23 | use utf8; | 
|  | 24 | use open qw(:std utf8); | 
|  | 25 |  | 
|  | 26 | die unless @ARGV == 1; | 
|  | 27 |  | 
|  | 28 | my @snaps; | 
|  | 29 | open my $fh, '<', $ARGV[0] or die; | 
|  | 30 | { local $/ = 'snapshot='; @snaps = <$fh>; } | 
|  | 31 | close $fh or die; | 
|  | 32 |  | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 33 | 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] | 34 | for (@snaps) | 
|  | 35 | { | 
|  | 36 | my ($heap, $heap_extra, $stack) = m{ | 
|  | 37 | mem_heap_B=(\d+)\n | 
|  | 38 | mem_heap_extra_B=(\d+)\n | 
|  | 39 | mem_stacks_B=(\d+) | 
|  | 40 | }xm; | 
|  | 41 | next unless defined $heap; | 
|  | 42 | my $total = $heap + $heap_extra + $stack; | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 43 | if( $total > $max ) { | 
|  | 44 | ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack); | 
|  | 45 | } | 
| Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 46 | } | 
|  | 47 |  | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 48 | printf "$max (heap $max_heap+$max_he, stack $max_stack)\n"; |