Jump to content
Sign in to follow this  
VelvetElvis

Turn off TimerInit() ?

Recommended Posts

VelvetElvis

Near the beginning of my app, I have

$startTime = TimerInit()

Then I test it in a loop, taking action if it runs too long, then don't bother with it again.

Is there:

(1) a way to turn it off? (I'm not using #include <Timers.au3>, just the built-in functions.)

or

(2) any performance hit having an unneeded timer accumulating time for the rest of the time the app runs?

Thanks!

Share this post


Link to post
Share on other sites
johnmcloud

Stop? TimerDiff "stop" it, show the difference and if you call TimerInit() again it start from 0

Don't understand how you use it in a loop, you use Do...Until or what?

$sec = "3000"
$timer = TimerInit()
Do
; Your Func
Until TimerDiff($timer) >= $sec
Edited by johnmcloud

Share this post


Link to post
Share on other sites
FireFox

I think he wants to know if it's possible to release the ressources used by the function TimerInit.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
guinness

Stop? TimerDiff "stop" it

Are you sure?

Example()

Func Example()
    Local Const $hTimer = TimerInit()
    Local $iDiff = 0, $iDiffPrevious = 0
    While 1
        $iDiff = Round(TimerDiff($hTimer))
        If Not ($iDiff = $iDiffPrevious) Then
            $iDiffPrevious = $iDiff
            ConsoleWrite($iDiff & @CRLF)
        EndIf
        If TimerDiff($hTimer) > 2000 Then ExitLoop
    WEnd
EndFunc   ;==>Example

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
johnmcloud

Stop was between "" ;)

Anyway i don't know if can be release the resources, TimerInt is like a DLLCall of QueryPerformanceCounter ( kernel32.dll )

Share this post


Link to post
Share on other sites
VelvetElvis

I think he wants to know if it's possible to release the ressources used by the function TimerInit.

Thanks. Yes, that's correct

Share this post


Link to post
Share on other sites
Melba23

VelvetElvis,

TimerInit uses no resources other than the variable in which you store the returned value. it is not a timer as such, it just returns a numerical timestamp which you can then use with TimerDiff to determine an elapsed time. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
VelvetElvis

Don't understand how you use it in a loop, you use Do...Until or what?

While 1
$target = _ImageSearch(@ScriptDir & "\Clips\test.gif", 1, $x1, $y1, 0); Testing only
If $target = 1 Then ExitLoop

; Timeout if Java hasn't loaded HOD in 30 seconds
If TimerDiff($startTime) > 30000 Then
     MsgBox(8208, $appname, "Timed out waiting for HOSTS icons to load." & @CRLF & "Please logon manually.")
     Exit
EndIf
Sleep(500)
WEnd

I could've used TimerDiff() instead of the "While 1" too. It's just in the initial stages.

Share this post


Link to post
Share on other sites
VelvetElvis

VelvetElvis,

TimerInit uses no resources other than the variable in which you store the returned value. it is not a timer as such, it just returns a numerical timestamp which you can then use with TimerDiff to determine an elapsed time. :)

M23

Thanks M23. That's what I needed.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×