quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

massif_max.pl (849B)


      1 #!/usr/bin/env perl
      2 
      3 # Parse a massif.out.xxx file and output peak total memory usage
      4 #
      5 # Copyright The Mbed TLS Contributors
      6 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
      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 
     21 my ($max, $max_heap, $max_he, $max_stack) = (0, 0, 0, 0);
     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;
     31     if( $total > $max ) {
     32         ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack);
     33     }
     34 }
     35 
     36 printf "$max (heap $max_heap+$max_he, stack $max_stack)\n";