Difference between revisions of "Development Team/Profiling"

From Sugar Labs
Jump to navigation Jump to search
(No difference)

Revision as of 05:14, 25 August 2008


Memory

ps_mem

Try to determine how much RAM is currently being used per program. The shared RAM is problematic to calculate, and this script automatically selects the most accurate method available for your kernel.

original script at http://www.pixelbeat.org/scripts/ps_mem.py
patched version at http://dev.laptop.org/~rlucchese/scripts/ps_mem
patch:
--- ps_mem.orig	2008-07-22 08:00:58.000000000 +0200
+++ ps_mem	2008-08-25 10:01:35.000000000 +0200
@@ -117,14 +117,16 @@
     return (Private, Shared)
 
 def getCmdName(pid):
-    cmd = file("/proc/%d/status" % pid).readline()[6:-1]
-    exe = os.path.basename(os.path.realpath("/proc/%d/exe" % pid))
-    if exe.startswith(cmd):
-        cmd=exe #show non truncated version
-        #Note because we show the non truncated name
-        #one can have separated programs as follows:
-        #584.0 KiB +   1.0 MiB =   1.6 MiB    mozilla-thunder (exe -> bash)
-        # 56.0 MiB +  22.2 MiB =  78.2 MiB    mozilla-thunderbird-bin
+    cmd = file("/proc/%d/cmdline" % pid).readline()[:60]
+    if not len(cmd):
+        cmd = file("/proc/%d/status" % pid).readline()[6:-1]
+        exe = os.path.basename(os.path.realpath("/proc/%d/exe" % pid))
+        if exe.startswith(cmd):
+            cmd=exe #show non truncated version
+            #Note because we show the non truncated name
+            #one can have separated programs as follows:
+            #584.0 KiB +   1.0 MiB =   1.6 MiB    mozilla-thunder (exe -> bash)
+            # 56.0 MiB +  22.2 MiB =  78.2 MiB    mozilla-thunderbird-bin
     return cmd
 
 cmds={}