dufran3 Posted May 4, 2007 Posted May 4, 2007 I was trying to create a function to do some profiling, like they have in C. Here is what I have so far. $StartTime = TimereInit() Call(_SleepFunction) $EndTime = TimerDiff($StartTime) $EndTime /=1000 ;This is to change from milliseconds to seconds $EndTimeFormatted = StringSplit($EndTime, '.') ; This is to remove all the digits after the decimal point $MsgBox(0,'Time', 'Function call took: ' & $EndTimeFormatted[1] & ' second(s)') Func _SleepFunction() Sleep(2000) EndFuncoÝ÷ زÚòx-¢f¤y§îËb¢{ajÒ¢é]q©e¥«,¶ÛbëÚ®&æ§v¯z+]¡©e¡ûaƧv·º¹íçè®fµçmg£¯z²7öiè¶Ë«z0# .×h¶"IèÂØ^è¬j«¨µº¹êº_ºw-ÛºÒ7öiè¶Ë«z'í+0¢é]ÂäêÞÌ!jÛayû§rب .Ù"Ú$)jëh×6$StartTime = TimerInit() ;getting start time in millisecons Call(_SleepFunction) ; calling sleep function $EndTime = TimerDiff($StartTime) ; gets difference between start and end Call(_Timer, $EndTime) ;formatting $EndTime MsgBox(0,'Timer','Function call took: ' & $EndTimeFormatted[1] & ' second(s)') ;Display formatted time in message box Func _Timer($EndTime) $EndTime /=1000 $EndTimeFormatted = StringSplit($EndTime, '.') ;<--- Here is the problem...Can I use return here, if so, then how do I use it. EndFunc Func _SleepFunction() Sleep(2000) EndFunc Is there a better way of doing this. I was hoping that I would have a function that I would call before calling a function, then one after it was finished, and it would give me the time it took to run....
PsaltyDS Posted May 4, 2007 Posted May 4, 2007 Read the help file for Round() to do this much more easily: $EndTimeFormatted = StringSplit($EndTime, '.') ; This is to remove all the digits after the decimal point Read the help file for _TicksToTime() in the Date.au3 UDF for the conversion. When you have some spare time, read the help file. P.S. Read the help file. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
dufran3 Posted May 4, 2007 Author Posted May 4, 2007 I read the help file all day long man...sorry, must have missed it.
Valuater Posted May 4, 2007 Posted May 4, 2007 I just use one line for seconds $dif = int(TimerDiff($begin)) / 1000 8)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now