Revision: 21150
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21150
Author:   jaguarandi
Date:     2009-06-25 12:42:22 +0200 (Thu, 25 Jun 2009)

Log Message:
-----------
Added getrusage (so that it can use "user time" instead of "wall time")

Modified Paths:
--------------
    branches/soc-2009-jaguarandi/test/html.py
    branches/soc-2009-jaguarandi/test/test.py

Modified: branches/soc-2009-jaguarandi/test/html.py
===================================================================
--- branches/soc-2009-jaguarandi/test/html.py   2009-06-25 10:14:51 UTC (rev 
21149)
+++ branches/soc-2009-jaguarandi/test/html.py   2009-06-25 10:42:22 UTC (rev 
21150)
@@ -110,7 +110,10 @@
                        else:
                                time = run["time"]*1000
 
-                               info = '<span 
class="block">'+"%02d:%02d.%03d"%(time/60000, (time/1000)%60, 
time%1000)+'</span>'
+                               info = '<span class="block">'+"%02d:%02d.%03d 
clock time"%(time/60000, (time/1000)%60, time%1000)+'</span>'
+                               if "getrusage" in run and "utime" in 
run["getrusage"]:
+                                       t = run["getrusage"]["utime"]*1000
+                                       info += '<span 
class="block">'+"%02d:%02d.%03d user time"%(t/60000, (t/1000)%60, 
t%1000)+'</span>'
 
                                # comparison result
                                

Modified: branches/soc-2009-jaguarandi/test/test.py
===================================================================
--- branches/soc-2009-jaguarandi/test/test.py   2009-06-25 10:14:51 UTC (rev 
21149)
+++ branches/soc-2009-jaguarandi/test/test.py   2009-06-25 10:42:22 UTC (rev 
21150)
@@ -4,6 +4,7 @@
 import time
 import subprocess
 import persistent
+import resource
 
 class Case(dict):
        def __init__(self, arg = {}):
@@ -13,21 +14,55 @@
                print self["name"]+":","test not implemented",self["type"]
                return TestRun.RESULT_NONE
                
+               
+       #TODO improve this (measure memory .. etc.. )
        def run_cmd(self, cmd, test):
+               return self.unix_run_cmd(cmd,test)
+#              return self.non_unix_run_cmd(cmd,test)
+
+       
+       def unix_run_cmd(self, cmd, test):
+               old_r = resource.getrusage(resource.RUSAGE_CHILDREN)
                dt = time.time()
                proc = subprocess.Popen(cmd,stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
                out, err = proc.communicate()
                dt = time.time()-dt
+               new_r = resource.getrusage(resource.RUSAGE_CHILDREN)
 
+               test["getrusage"] = {}
+               keys = { "utime": 0, "stime":1, "minflt":6, "maxflt":7, 
"nvcsw":14, "nivcsw":15 }
+               for field in keys:
+                       test["getrusage"][field] = new_r[ keys[field] ] - 
old_r[ keys[field] ]
+                       
+               print test["getrusage"]
+
                test["cmdline"] = cmd
                test["time"] = dt
                test["stderr"] = err
                test["stdout"] = out
                test["exit_status"] = proc.returncode
                
+               print test
                return proc.returncode
 
 
+       def non_unix_run_cmd(self,cmd,test):
+               dt = time.time()
+               
+               proc = subprocess.Popen(cmd,stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
+               out, err = proc.communicate()
+               dt = time.time()-dt
+
+               test["cmdline"] = cmd
+               test["time"] = dt
+               test["stderr"] = err
+               test["stdout"] = out
+               test["exit_status"] = proc.returncode
+               
+               return proc.returncode
+       
+
+
 class Render(Case):
        __name__ = "render"
        
@@ -113,10 +148,9 @@
                                Render(self["case"]).run(self)
 
                        self.save_results()
-               except:
-                       #TODO print exception
+               except Exception:
                        print "Failed to process test run:",self.result_path
-                       os._exit(-1)
+                       raise
        
 
##########################################################################################
 def get(machine,build,case):


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to