2 easy timing Procedures

Share your advanced PureBasic knowledge/code with the community.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

2 easy timing Procedures

Post by Zebuddi123 »

2 procedure`s for measuring time up to hours using the new select case "To" feature

Code: Select all

ProcedureDLL  MSMS(); - use MSMS() at the start And MSME() To measure corresponding time up To hours
	Global millistart
	millistart=ElapsedMilliseconds()
EndProcedure

ProcedureDLL.s MSME()
	milliend=ElapsedMilliseconds()
	x=milliend-millistart
	Select x     
		Case 0 To 999
			ProcedureReturn "Time Taken = "+Str(x)+" ms"
		Case 1000 To 59999
			ProcedureReturn "Time Taken = "+StrD(x/1000 ,2)+" secs"
		Case 60000 To 3599999
			ProcedureReturn "Time Taken = "+StrD(((x/1000) /60) ,2)+" mins"
		Case 3600000 To 215999999
			ProcedureReturn "Time Taken = "+StrD((((x/1000) /60) /60) ,2)+" Hour`s"
	EndSelect
EndProcedure
Example :

Code: Select all

MSMS()
Delay(123400)
Debug MSME()
Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: 2 easy timing Procedures

Post by IdeasVacuum »

Nice - thanks Zebuddi123 8)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply