This example is provided to show how to check the time consumption in
Scorpion
#------------------------------------------------------
# An example that is part of a PythonScript tool
#------------------------------------------------------
# these values are defined in the Central Start script of Scorpion
global time,min,max,mean
# init all values if time is zero
if time == 0:
# read a timer with milliseconds resolution
t0 = GetValue('System.MSecSinceMidnight')
time = t0
min = 10000
max = 0
mean = 0
else:
# read a timer with milliseconds resolution
t0 = GetValue('System.MSecSinceMidnight')
# calculates the times since this script was run in seconds
cyclus = (t0-time)/1000.0
# calculates min and max values
if cyclus > max:
max = cyclus
if cyclus < min:
min = cyclus
mean = mean*0.9 + cyclus*0.1 # caculates a running mean
value
# print cyclus and running mean to console windows
print ' cyclus - ',t0 - time, ' mean - ',mean
# remember counter
time = t0
|