Jump to content

Development Team/Profiling: Difference between revisions

From Sugar Labs
New page: <noinclude>{{ GoogleTrans-en | es =show | bg =show | zh-CN =show | zh-TW =show | hr =show | cs =show | da =show | nl =show | fi =show | fr =show | de =show | el =show | hi =show | it =show...
 
No edit summary
Line 3: Line 3:
===Memory===
===Memory===
====ps_mem====
====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
:original script at http://www.pixelbeat.org/scripts/ps_mem.py
:patched version at http://dev.laptop.org/~rlucchese/scripts/ps_mem
:patched version at http://dev.laptop.org/~rlucchese/scripts/ps_mem

Revision as of 03:55, 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={}