Introduced paired events for processes.
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 23 Nov 2011 00:53:58 +0000 (01:53 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 23 Nov 2011 00:53:58 +0000 (01:53 +0100)
pdm/perf.py

index 0ff02a1..de2dba5 100644 (file)
@@ -1,4 +1,4 @@
-import os, sys, resource, time, socket
+import os, sys, resource, time, socket, threading
 
 class attrinfo(object):
     def __init__(self, desc = None):
 
 class attrinfo(object):
     def __init__(self, desc = None):
@@ -98,6 +98,25 @@ class event(object):
     def __init__(self):
         self.time = time.time()
 
     def __init__(self):
         self.time = time.time()
 
+idlock = threading.Lock()
+procevid = 0
+class startevent(event):
+    def __init__(self):
+        super(startevent, self).__init__()
+        global procevid
+        idlock.acquire()
+        try:
+            self.id = procevid
+            procevid += 1
+        finally:
+            idlock.release()
+
+class finishevent(event):
+    def __init__(self, start, aborted):
+        super(finishevent, self).__init__()
+        self.id = start.id
+        self.aborted = aborted
+
 sysres = staticdir()
 itime = time.time()
 ires = resource.getrusage(resource.RUSAGE_SELF)
 sysres = staticdir()
 itime = time.time()
 ires = resource.getrusage(resource.RUSAGE_SELF)