[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52724] trunk/lib/tests/rendering/cycles/ test_utils.py: Cycles Test Suite:

Thomas Dinges blender at dingto.org
Mon Dec 3 02:42:29 CET 2012


Revision: 52724
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52724
Author:   dingto
Date:     2012-12-03 01:42:26 +0000 (Mon, 03 Dec 2012)
Log Message:
-----------
Cycles Test Suite:
* Some code refactoring, use more functions.
* The script now also saves a log file, which contains blendfile name, svn revision, and render time in seconds. 

Modified Paths:
--------------
    trunk/lib/tests/rendering/cycles/test_utils.py

Modified: trunk/lib/tests/rendering/cycles/test_utils.py
===================================================================
--- trunk/lib/tests/rendering/cycles/test_utils.py	2012-12-03 00:36:23 UTC (rev 52723)
+++ trunk/lib/tests/rendering/cycles/test_utils.py	2012-12-03 01:42:26 UTC (rev 52724)
@@ -1,26 +1,62 @@
 import os
+import sys
 import bpy
+import time
 
-def main():
+def write_log_file(seconds, dir, blend_file, shading):
+    rev = get_blender_revision()
+    seconds = round(seconds, 2)
+    path = "%s/test_renders/log.txt" % dir
+    
+    try:
+        logfile = open(path, "a")
+        try:
+            logfile.write('%s - %s - %s - %s seconds\n' % (blend_file, rev, shading, seconds))
+        finally:
+            logfile.close()
+    except IOError:
+        pass
 
-    # Only run in background mode
-    if bpy.app.background:
+def is_background():
+    return bpy.app.background
     
-        # Get the cycles test directory
-        filepath = bpy.data.filepath
-        blend_files_dir = os.path.dirname(filepath)
-        cycles_dir = os.path.dirname(blend_files_dir)
+def get_blender_revision():
+    return bpy.app.build_revision
 
-        # Get the filename without ending
-        basename = os.path.basename(filepath)
-        filename = os.path.splitext(basename)[0]
-
-        # ##### SVM #####
+def set_shading_system(system):
+    if system == 'svm':
         bpy.context.scene.cycles['shading_system'] = 0
-        bpy.context.scene.render.filepath = "%s/test_renders/%s_svm" % (cycles_dir, filename)
-        bpy.ops.render.render(write_still=True)
+    elif system == 'osl':
+        bpy.context.scene.cycles['shading_system'] = 1
 
-        # ##### OSL #####
-        bpy.context.scene.cycles['shading_system'] = 1
-        bpy.context.scene.render.filepath = "%s/test_renders/%s_osl" % (cycles_dir, filename)
-        bpy.ops.render.render(write_still=True)
\ No newline at end of file
+def main():
+    # Only run in background mode
+    if not is_background():
+        return
+
+    # Get the cycles test directory
+    filepath = bpy.data.filepath
+    blend_files_dir = os.path.dirname(filepath)
+    cycles_dir = os.path.dirname(blend_files_dir)
+
+    # Get the filename without ending
+    basename = os.path.basename(filepath)
+    filename = os.path.splitext(basename)[0]
+
+    # ##### SVM #####
+    set_shading_system("svm")
+    bpy.context.scene.render.filepath = "%s/test_renders/%s_svm" % (cycles_dir, filename)
+    
+    start_time = time.time()
+    bpy.ops.render.render(write_still=True)
+    end_time = time.time()
+    write_log_file((end_time-start_time), cycles_dir, basename, "svm")
+
+    # ##### OSL #####
+    set_shading_system("osl")
+    bpy.context.scene.render.filepath = "%s/test_renders/%s_osl" % (cycles_dir, filename)
+    
+    start_time = time.time()
+    bpy.ops.render.render(write_still=True)
+    end_time = time.time()
+    write_log_file((end_time-start_time), cycles_dir, basename, "osl")
\ No newline at end of file




More information about the Bf-blender-cvs mailing list