loop execution time

Hi!
is there a way to get elapsed time during a loop execution? for exemple showing the elapsed time in label.text (second by second)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tinnnpo's picture

thank you all

thank you all for yours inputs I didn't know timeStamp() function however what I wanted to do is real time chronometre but it seems impossible since even max render counter is not live :)

Anubis's picture

elapsed time + time left?

As I remember how Max measure elapsed time and time left for rendering statistic, in scripting it may look something like:

beginTime = timeStamp()
for t = 10 to 60 do
(
	strTime = timeStamp()
	render frame:t vfb:off
	endTime = timeStamp()
 
	endFrmTime = endTime - strTime
	elapsedTime = endTime - beginTime
	timeLeft = (60 - t + 1) * endFrmTime
 
	format "Elapsed Time: %\n" elapsedTime
	format "Time Left: %\n" timeLeft
)

In other words (a bit fake) the calculation of the time left is based on the last elapsed time. Not perfect but better than nothing.

my recent MAXScripts RSS (archive here)

miauu's picture

Use the progressbar control.

Use the progressbar control. I think that you can't calculate how long will take the loop execution. You can use counter and can show in label "processed/total count".

(
	cnt = 0
	for i = 1 to selection.count do
	(
		cnt += 1
		format "Processed % of % \n " cnt selection.count 
	)
)
br0t's picture

You can use timeStamp() to

You can use

timeStamp()

to get the milliseconds since midnight I think, or use

localTime

to get date and time as a string. Do this at the start and end of your loop and calculate the difference (With localTime you'll have to do some string formatting, e.g. with substring and with timeStamp() you'd have to convert it to seconds, minutes etc. by division)
Cheers

Never get low & slow & out of ideas

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.