Jump to content

Recommended Posts

Posted

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....

Posted

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.

:D

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...