https://bugs.kde.org/show_bug.cgi?id=387080

            Bug ID: 387080
           Summary: [PATCH] Add --only-peak option to ms_print
           Product: valgrind
           Version: unspecified
          Platform: unspecified
                OS: All
            Status: UNCONFIRMED
          Severity: wishlist
          Priority: NOR
         Component: massif
          Assignee: n...@valgrind.org
          Reporter: vz-...@zeitlins.org
  Target Milestone: ---

I made a trivial patch to show just the peak heap usage as it was convenient
for me to compare different implementations of the same feature:

>From 6b57c2b789498780378c26a3bbc5cc81593fb1f3 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vz-...@zeitlins.org>
Date: Sat, 18 Nov 2017 18:16:43 +0100
Subject: [PATCH] Add --only-peak option to ms_print

Show just the peak heap usage if this option is specified.
---
 massif/ms_print.in | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/massif/ms_print.in b/massif/ms_print.in
index 565fd6506..e030569c5 100755
--- a/massif/ms_print.in
+++ b/massif/ms_print.in
@@ -40,6 +40,9 @@ my $cmd;
 # Time unit used in profile.
 my $time_unit;

+# Indicates whether only peak memory usage should be given.
+my $only_peak = 0;
+
 # Threshold dictating what percentage an entry must represent for us to
 # bother showing it.
 my $threshold = 1.0;
@@ -72,6 +75,7 @@ usage: ms_print [options] massif-out-file
   options for the user, with defaults in [ ], are:
     -h --help             show this message
     --version             show version
+    --only-peak           show only the peak memory usage [no]
     --threshold=<m.n>     significance threshold, in percent [$threshold]
     --x=<4..1000>         graph width, in columns [72]
     --y=<4..1000>         graph height, in rows [20]
@@ -115,6 +119,9 @@ sub process_cmd_line()
             if ($arg =~ /^--version$/) {
                 die("ms_print-$version\n");

+            # --only-peak
+            } elsif ($arg eq '--only-peak') {
+                $only_peak = 1;
             # --threshold=X (tolerates a trailing '%')
             } elsif ($arg =~ /^--threshold=([\d\.]+)%?$/) {
                 $threshold = $1;
@@ -468,6 +475,12 @@ sub read_input_file()
     close(INPUTFILE);
     close(TMPFILE);

+    if ($only_peak) {
+        print "Peak memory usage: $peak_mem_total_szB bytes\n";
+        unlink($tmp_file);
+        return;
+    }
+
     #-------------------------------------------------------------------------
     # Print header.
     #-------------------------------------------------------------------------
--
2.14.1.459.g238e487ea9

If you think this can be useful, I could add its description to the docs too
(especially if someone mentions which file(s) should be modified).

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to