VelvetElvis Posted February 25, 2013 Share Posted February 25, 2013 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! Link to comment Share on other sites More sharing options...
johnmcloud Posted February 25, 2013 Share Posted February 25, 2013 (edited) 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 February 25, 2013 by johnmcloud Link to comment Share on other sites More sharing options...
FireFox Posted February 25, 2013 Share Posted February 25, 2013 I think he wants to know if it's possible to release the ressources used by the function TimerInit. Link to comment Share on other sites More sharing options...
guinness Posted February 25, 2013 Share Posted February 25, 2013 Stop? TimerDiff "stop" itAre 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
johnmcloud Posted February 25, 2013 Share Posted February 25, 2013 Stop was between "" Anyway i don't know if can be release the resources, TimerInt is like a DLLCall of QueryPerformanceCounter ( kernel32.dll ) Link to comment Share on other sites More sharing options...
VelvetElvis Posted February 25, 2013 Author Share Posted February 25, 2013 I think he wants to know if it's possible to release the ressources used by the function TimerInit.Thanks. Yes, that's correct Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 25, 2013 Moderators Share Posted February 25, 2013 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
VelvetElvis Posted February 25, 2013 Author Share Posted February 25, 2013 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. Link to comment Share on other sites More sharing options...
VelvetElvis Posted February 25, 2013 Author Share Posted February 25, 2013 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. M23Thanks M23. That's what I needed. Link to comment Share on other sites More sharing options...
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