PDA

View Full Version : "Python MakePreviewTimed" for video benchmarks



Celshader
05-06-2013, 09:05 AM
Last night I ran into a former co-worker who now benchmarks (http://www.tomshardware.com/reviews/p500x-p900dx-workstation-review,3311-8.html) workstations for Tom's Hardware. His current method of benchmarking GPU performance on LightWave 3D is to make a preview of a 1.7 million poly object while hovering next to the computer with a stopwatch app running on his phone.

I wrote this script to help time previews for him. Right now, however, my script has a flaw: it includes the time it takes for the user to click "End Preview." If the user waits an hour to click End Preview, an hour will be added to the total time. So this script still requires the user to hover next to the computer, but for a different reason.

I'm posting the code here in case it proves useful to anyone else.

LightWave 11.5 "single-shot" formatting for generic scripts:



import lwsdk, time

def makePreview():
ga = lwsdk.GenericAccess()
ga.evaluate("MakePreview")

def info(title, message):
mf = lwsdk.LWMessageFuncs()
mf.info(title, message)

t = time.time()
makePreview()
s = time.time() - t
message = "%0.3f seconds to make that preview and click \"End Preview\"." % s
title = "%0.3f seconds" % s
info(title, message)


Same code in the more formal LightWave 11.x formatting:



import lwsdk, time

__author__ = "Jennifer Hachigian"
__copyright__ = "Copyright (C) 2012 Jennifer Hachigian"
__version__ = "1.0"
__maintainer__ = "Not Me"
__email__ = "[email protected]"
__status__ = "Production"
__lwver__ = "11"



def makePreview(ga):
command = "MakePreview"
ga.evaluate(ga.data, command)

def info(title, message):
lwMF = lwsdk.LWMessageFuncs()
lwMF.info(title, message)


class MakePreviewTimed(lwsdk.IGeneric):
def __init__(self, context):
super(MakePreviewTimed, self).__init__()

# LWGeneric -------------------------------------------
def process(self, ga):
t = time.time()
makePreview(ga)
s = time.time() - t
message = "%0.3f seconds to make that preview and click \"End Preview\"." % s
title = "%0.3f seconds" % s
info(title, message)
return lwsdk.AFUNC_OK



ServerTagInfo = [
( "Python MakePreviewTimed", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
( "Make Preview - Timed", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )
]

ServerRecord = { lwsdk.GenericFactory("LW_MakePreviewTimed", MakePreviewTimed) : ServerTagInfo }