blob: f7fa919b4f1fa194ecec278494fb40d1a8a8137f [file] [log] [blame]
fbrosson3a745712018-04-04 22:26:56 +00001#!/usr/bin/env perl
Manuel Pégourié-Gonnard4d5cc112014-11-25 12:21:48 +01002
3# Parse a massif.out.xxx file and output peak total memory usage
Bence Szépkútib7246ad2020-05-26 00:33:31 +02004#
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é-Gonnard4d5cc112014-11-25 12:21:48 +01008
9use warnings;
10use strict;
11
12use utf8;
13use open qw(:std utf8);
14
15die unless @ARGV == 1;
16
17my @snaps;
18open my $fh, '<', $ARGV[0] or die;
19{ local $/ = 'snapshot='; @snaps = <$fh>; }
20close $fh or die;
21
Manuel Pégourié-Gonnardc6dbc8e2014-12-01 14:05:45 +010022my ($max, $max_heap, $max_he, $max_stack) = (0, 0, 0, 0);
Manuel Pégourié-Gonnard4d5cc112014-11-25 12:21:48 +010023for (@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é-Gonnardc6dbc8e2014-12-01 14:05:45 +010032 if( $total > $max ) {
33 ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack);
34 }
Manuel Pégourié-Gonnard4d5cc112014-11-25 12:21:48 +010035}
36
Manuel Pégourié-Gonnardc6dbc8e2014-12-01 14:05:45 +010037printf "$max (heap $max_heap+$max_he, stack $max_stack)\n";