VelvetElvis 2 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! Share this post Link to post Share on other sites
johnmcloud 26 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 Share this post Link to post Share on other sites
FireFox 260 Posted February 25, 2013 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_UDFMy Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme makerMy Examples : Capture tool | IP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewerMy 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 1,517 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 Share this post Link to post Share on other sites
johnmcloud 26 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 ) Share this post Link to post Share on other sites
VelvetElvis 2 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 Share this post Link to post Share on other sites
Melba23 3,396 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 Share this post Link to post Share on other sites
VelvetElvis 2 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. Share this post Link to post Share on other sites
VelvetElvis 2 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. Share this post Link to post Share on other sites