summaryrefslogtreecommitdiffstats
path: root/tools/memory_watcher/scripts/summary.pl
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-09 02:21:46 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-09 02:21:46 +0000
commit8687244a01e4333ed0edb429bdefbf88f83e965b (patch)
tree86d85e42a9ac9ead118607d843dc6fab8b55c1ca /tools/memory_watcher/scripts/summary.pl
parente724cb43e666972363380de0f6eba349160ac28c (diff)
downloadchromium_src-8687244a01e4333ed0edb429bdefbf88f83e965b.zip
chromium_src-8687244a01e4333ed0edb429bdefbf88f83e965b.tar.gz
chromium_src-8687244a01e4333ed0edb429bdefbf88f83e965b.tar.bz2
Add mbelshe's memwatcehr scripts to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/memory_watcher/scripts/summary.pl')
-rw-r--r--tools/memory_watcher/scripts/summary.pl109
1 files changed, 109 insertions, 0 deletions
diff --git a/tools/memory_watcher/scripts/summary.pl b/tools/memory_watcher/scripts/summary.pl
new file mode 100644
index 0000000..35c0716
--- /dev/null
+++ b/tools/memory_watcher/scripts/summary.pl
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+#
+# Summarizes output from memtrace using a set of heuristics
+#
+
+sub process_stdin() {
+ my %leaks = ();
+ my $total_bytes = 0;
+
+ while(<STDIN>) {
+ my $line = $_;
+ chomp($line);
+ my $bytes, $loc;
+ ($bytes, $loc) = ($line =~ m/[ \t]*([0-9]*)[ \t]*[0-9\.%]*[ \t]*(.*)/);
+ my $location_blame = "";
+
+# print "Found: $bytes, $loc\n";
+
+ $total_bytes += $bytes;
+
+ if ($loc =~ m/v8/) {
+ $location_blame = "v8";
+ } elsif ($loc =~ m/sqlite/) {
+ $location_blame = "sqlite";
+ } elsif ($loc =~ m/SkBitmap/) {
+ $location_blame = "skia";
+ } elsif ($loc =~ m/disk_cache/) {
+ $location_blame = "disk cache";
+ } elsif ($loc =~ m/skia/) {
+ $location_blame = "skia";
+ } elsif ($loc =~ m/:WSA/) {
+ $location_blame = "net";
+ } elsif ($loc =~ m/dns/) {
+ $location_blame = "net";
+ } elsif ($loc =~ m/trunk\\net/) {
+ $location_blame = "net";
+ } elsif ($loc =~ m/WinHttp/) {
+ $location_blame = "WinHttp";
+ } elsif ($loc =~ m/:I_Crypt/) {
+ $location_blame = "WinHttpSSL";
+ } elsif ($loc =~ m/CryptGetTls/) {
+ $location_blame = "WinHttpSSL";
+ } elsif ($loc =~ m/WinVerifyTrust/) {
+ $location_blame = "WinHttpSSL";
+ } elsif ($loc =~ m/Cert/) {
+ $location_blame = "WinHttpSSL";
+ } elsif ($loc =~ m/plugin/) {
+ $location_blame = "plugin";
+ } elsif ($loc =~ m/NP_/) {
+ $location_blame = "plugin";
+ } elsif ($loc =~ m/hunspell/) {
+ $location_blame = "hunspell";
+ } elsif ($loc =~ m/decoder/) {
+ $location_blame = "img decoder";
+ } elsif ($loc =~ m/TextCodec/) {
+ $location_blame = "fonts";
+ } elsif ($loc =~ m/glyph/) {
+ $location_blame = "fonts";
+ } elsif ($loc =~ m/cssparser/) {
+ $location_blame = "webkit css";
+ } elsif ($loc =~ m/::CSS/) {
+ $location_blame = "webkit css";
+ } elsif ($loc =~ m/Arena/) {
+ $location_blame = "webkit arenas";
+ } elsif ($loc =~ m/IPC/) {
+ $location_blame = "ipc";
+ } elsif ($loc =~ m/trunk\\chrome\\browser/) {
+ $location_blame = "browser";
+ } elsif ($loc =~ m/trunk\\chrome\\renderer/) {
+ $location_blame = "renderer";
+ } elsif ($loc =~ m/webcore\\html/) {
+ $location_blame = "webkit webcore html";
+ } elsif ($loc =~ m/webkit.*string/) {
+ $location_blame = "webkit strings";
+ } elsif ($loc =~ m/htmltokenizer/) {
+ $location_blame = "webkit HTMLTokenizer";
+ } elsif ($loc =~ m/javascriptcore/) {
+ $location_blame = "webkit javascriptcore";
+ } elsif ($loc =~ m/webkit/) {
+ $location_blame = "webkit other";
+# print "$location_blame: ($bytes) $loc\n";
+ } else {
+ $location_blame = "unknown";
+# print "$location_blame: ($bytes) $loc\n";
+ }
+
+ # surface large outliers
+ if ($bytes > 1000000 && $location_blame eq "unknown") {
+ $location_blame = $loc;
+ }
+
+ $leaks{$location_blame} += $bytes;
+ }
+
+ # now dump our hash table
+ my $sum = 0;
+ my @keys = keys(%leaks);
+ for ($i=0; $i<@keys; $i++) {
+ my $key = @keys[$i];
+ printf "%8d\t%3.2f%%\t%s\n", $leaks{$key}, (100* $leaks{$key} / $total_bytes), $key;
+ $sum += $leaks{$key};
+ }
+ print("TOTAL: $sum\n");
+}
+
+
+# ----- Main ------------------------------------------------
+
+process_stdin();