| 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 | 
| Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 6 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | 
| Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 7 |  | 
|  | 8 | use warnings; | 
|  | 9 | use strict; | 
|  | 10 |  | 
|  | 11 | use utf8; | 
|  | 12 | use open qw(:std utf8); | 
|  | 13 |  | 
|  | 14 | die unless @ARGV == 1; | 
|  | 15 |  | 
|  | 16 | my @snaps; | 
|  | 17 | open my $fh, '<', $ARGV[0] or die; | 
|  | 18 | { local $/ = 'snapshot='; @snaps = <$fh>; } | 
|  | 19 | close $fh or die; | 
|  | 20 |  | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 21 | 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] | 22 | for (@snaps) | 
|  | 23 | { | 
|  | 24 | my ($heap, $heap_extra, $stack) = m{ | 
|  | 25 | mem_heap_B=(\d+)\n | 
|  | 26 | mem_heap_extra_B=(\d+)\n | 
|  | 27 | mem_stacks_B=(\d+) | 
|  | 28 | }xm; | 
|  | 29 | next unless defined $heap; | 
|  | 30 | my $total = $heap + $heap_extra + $stack; | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 31 | if( $total > $max ) { | 
|  | 32 | ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack); | 
|  | 33 | } | 
| Manuel Pégourié-Gonnard | 4d5cc11 | 2014-11-25 12:21:48 +0100 | [diff] [blame] | 34 | } | 
|  | 35 |  | 
| Manuel Pégourié-Gonnard | c6dbc8e | 2014-12-01 14:05:45 +0100 | [diff] [blame] | 36 | printf "$max (heap $max_heap+$max_he, stack $max_stack)\n"; |