From 4905d9910de168fb5bc9f1995a94717d0f52c4b9 Mon Sep 17 00:00:00 2001 From: "dp%netscape.com" Date: Wed, 9 Aug 2000 20:45:24 +0000 Subject: [PATCH] Perl script to analyze xpcom log output and print results in html git-svn-id: svn://10.0.0.236/trunk@75899 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/doc/xpcom-log-analyze.pl | 207 +++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 mozilla/xpcom/doc/xpcom-log-analyze.pl diff --git a/mozilla/xpcom/doc/xpcom-log-analyze.pl b/mozilla/xpcom/doc/xpcom-log-analyze.pl new file mode 100644 index 00000000000..08cdea274c9 --- /dev/null +++ b/mozilla/xpcom/doc/xpcom-log-analyze.pl @@ -0,0 +1,207 @@ +#!/usr/bin/perl + +# Perl script to analyze the log output from xpcom and print +# the results in html. +# +# To get the xpcom log output to a file say xpcom.log: +# setenv NSPR_LOG_MODULES nsComponentManager:5 +# setenv NSPR_LOG_FILE xpcom.log +# ./mozilla +# +# +# To get registry (used to figure out progid mappings) +# ./regExport component.reg > registry.txt + +# Usage: +# +# a) To get simple output +# cat xpcom.log | perl xpcom-log-analyze.pl > xpcom-log.html +# +# b) To get all possible cid->progid mappings filled in +# cat xpcom.log registry.txt | perl xpcom-log-analyze.pl > xpcom-log.html +# +# +# Author: Suresh Duddi +# Created Aug 9 2000 + +while (<>) +{ + chomp; + if ( /ProgIDToClassID.*\}/ ) + { + # Passed progid to cid mapping. Add progid to cid mapping + $cid = GetCID(); + $progid = GetProgID(); + $progid_map{$cid} = $progid; + $progid_passed{$progid}++; + $nprogid_passed++; + next; + } + + if ( /ProgIDToClassID.*FAILED/ ) + { + # Failed progid. Collect it. + $progid = GetProgID(); + $progid_failed{$progid}++; + $nprogid_failed++; + next; + } + + if ( /CreateInstance.*succeeded/ ) + { + # Successful create instance + $objects{GetCID()}++; + $nobjects++; + next; + } + + if ( /CreateInstance.*FAILED/ ) + { + # Failed create instance + $objects_failed{GetCID()}++; + $nobjects_failed++; + next; + } + + if ( /: loading/ ) + { + $dll = GetDll(); + # make the name a little pretty + $dll =~ s/^.*bin\///; + $dll_loaded[@dll_loaded] = $dll; + next; + } + + if ( / classID - \{/ ) + { + # this is from the output of registry. Try to update progid_map + $cid = GetCID(); + $_ = ; + chomp; + $progid = $_; + $progid =~ s/^.*= //; + $progid_map{$cid} = $progid; + } +} + +PrintHTMLResults(); + + +sub GetProgID() { + # Get a proid from a line + my($progid) = $_; + $progid =~ s/^.*\((.*)\).*$/$1/; +# print "Got Progid: $progid\n"; + return $progid; +} + +sub GetCID() { + # Get a CID from a line + my($cid) = $_; + $cid =~ s/^.*\{(.*)\}.*$/$1/; +# print "Got cid: $cid\n"; + return $cid; +} + +sub GetDll() { + # Get a Dll from a line + my($dll) = $_; + $dll =~ s/^.*\"(.*)\".*$/$1/; +# print "Got dll: $dll\n"; + return $dll; +} + + +# +# Print the results of our log analysis in html +# +sub PrintHTMLResults() +{ + $now_time = localtime(); + print "XPCOM Log analysis dated: $now_time\n"; + print "\n"; + print "

\n"; + print "XPCOM Log analysis dated: $now_time\n"; + print "

\n"; +# ======================================================================== +# Performance analysis +# ======================================================================== + print "

Performance Analysis

\n"; + +# Number of dlls loaded + $n = @dll_loaded; + print "

Dlls Loaded : $n

\n"; + print "
\n";
+    PrintArray(@dll_loaded);
+    print "
\n"; + +# Objects created with a histogram + print "

Objects created : $nobjects

\n"; + print "
\n";
+    @sorted_key = SortKeyByValue(%objects);
+    foreach $cid (@sorted_key)
+    {
+        printf("%5d %s [%s]\n", $objects{$cid}, $cid, $progid_map{$cid});
+    }
+    print "
\n"; + +# Passed progid calls + print "

Succeeded ProgIDToClassID() : $nprogid_passed

\n"; + print "
\n";
+    @sorted_key = SortKeyByValue(%progid_passed);
+    foreach $progid (@sorted_key)
+    {
+        printf("%5d %s\n", $progid_passed{$progid}, $progid);
+    }
+    print "
\n"; + + +# ======================================================================== +# Error analysis +# ======================================================================== + print "

Error Analysis

\n"; + +# CreateInstance() FAILED + print "

Failed CreateInstance() : $nobjects_failed

\n"; + print "
\n";
+    @sorted_key = SortKeyByValue(%objects_failed);
+    foreach $cid (@sorted_key)
+    {
+        printf("%5d %s [%s]\n", $objects_failed{$cid}, $cid, $progid_map{$cid});
+    }
+    print "
\n"; + +# ProgIDToClassID() FAILED with a histogram + print "

Failed ProgIDToClassID() : $nprogid_failed

\n"; + print "
\n";
+    @sorted_key = SortKeyByValue(%progid_failed);
+    foreach $progid (@sorted_key)
+    {
+        printf("%5d %s\n", $progid_failed{$progid}, $progid);
+    }
+    print "
\n"; + +# end the html listing + print "\n"; +} + + +sub PrintArray() +{ + my(@array) = @_; + for ($i=0; $i<@array; $i++) + { + print "$array[$i]\n"; + } +} + +# +# Sort a given hash by reverse numeric order of value +# return the sorted keylist +# +sub SortKeyByValue() +{ + my(%hash) = @_; + my(@sorted_keys) = sort { $hash{$b} <=> $hash{$a} } keys %hash; + return @sorted_keys; +}