BinaryBrother Posted January 27, 2014 Share Posted January 27, 2014 Is the TimerInit handle destroyed if you overwrite the originating variable? I doubt it... but that would mean there's no way to destroy the Timer handle natively. I've seen Timer UDFs, but I was just curious as to the repercussions of creating hundreds of thousands on timer handles, by debugging certain things for a while to get average times. This is another time-wasting question that doesn't have any real goal or purpose, outside satisfying my curiosity! So I figured chat was a good place for it, once again. ^.^ Doesn't this create Timer handles that aren't getting destroyed? Does it hurt anything to use timers at the beginning of a script and never use them again? Aren't they just sitting there running? While 1 $TimerHandle = TimerInit() $TimerDiff = TimerDiff($TimerHandle) WEnd SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
JohnOne Posted January 27, 2014 Share Posted January 27, 2014 As I understand it, TimerInit() does not create a handle, rather a current timestamp. TimerDiff() creates another, and returns the difference. BinaryBrother 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted January 27, 2014 Share Posted January 27, 2014 (edited) Doesn't this create Timer handles that aren't getting destroyed? Does it hurt anything to use timers at the beginning of a script and never use them again? Aren't they just sitting there running?While 1 $TimerHandle = TimerInit() $TimerDiff = TimerDiff($TimerHandle) WEnd No, you are overwriting both variables in every loop with that code, plus what JohnOne said. Edited January 27, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
BinaryBrother Posted January 27, 2014 Author Share Posted January 27, 2014 (edited) Ahh! I hadn't actually tried looking at what TimerInit() returned. It returns the same as _Timer_Init() [uDF included with AutoIt 3.3.10.0], which is just the current timestamp. The documentation makes it sound so mysterious, saying that you shouldn't do anything with the TimerInit() return and it should be treated as a handle... http://screencast.com/t/X5bjXCk6s0yg Anywho, that perfectly answers my question. I could have figured that one out if I had just checked the return from TimerInit()! Thanks JohnOne & czardas! Edited January 27, 2014 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
BrewManNH Posted January 27, 2014 Share Posted January 27, 2014 TimerInit does not return a timestamp, it returns what Valik termed as an opaque handle, TimerDiff uses that handle to calculate the difference in time between the Init and the Diff. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 27, 2014 Share Posted January 27, 2014 He didn't say it is, he said it should be treated as. It is still not a real handle because that would cause a horrible memory leak if all those handles were created and not freed. Notice there is no TimerDestroy function. jaberwacky and BinaryBrother 2 Link to comment Share on other sites More sharing options...
BrewManNH Posted January 27, 2014 Share Posted January 27, 2014 He didn't say it is, he said it should be treated as.I'm not sure what it is you're saying here.It is still not a real handle because that would cause a horrible memory leak if all those handles were created and not freed. Notice there is no TimerDestroy function.That's why he called it an opaque handle, as in it's not a handle but a pointer to something else. But it's not a timestamp as others were saying above, which is what I was trying to point out. This stuff is above my ability level, I just wanted people to not get the wrong idea as to what timerinit returns. BinaryBrother 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JohnOne Posted January 27, 2014 Share Posted January 27, 2014 I'm sure there's a lot of voodoo under the bonnet, but it's essentially a timestamp at the user end. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
BrewManNH Posted January 27, 2014 Share Posted January 27, 2014 Even if it were a timestamp, there's no way to use it as one. You can't subtract two timerinits and get a time difference, at least not directly in a format that makes sense. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JohnOne Posted January 27, 2014 Share Posted January 27, 2014 Probably not, because I don't know how it is implemented, but I don't need to, Timerdiff deals with that. One might have a definition of what a standard timestamp might be, but however you cook it Timerdiff is a timestamp for Timerinit, regardless of it's type. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
BinaryBrother Posted January 27, 2014 Author Share Posted January 27, 2014 (edited) Sorry for not validating that it was a valid timestamp, I just glanced at it. Jesus... I had forgotten how blunt Valik was... Edited January 27, 2014 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
JohnOne Posted January 27, 2014 Share Posted January 27, 2014 wiki defines a timestamp as "a sequence of characters or encoded information identifying when a certain event occurred, usually giving date and time of day, sometimes accurate to a small fraction of a second" If that is not what TimerInit is, I'll eat my undercrackers. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
funkey Posted January 27, 2014 Share Posted January 27, 2014 (edited) #include <WinAPISys.au3> Global $iStart = TimerInit() Global $iStart2 = _WinAPI_QueryPerformanceCounter() ConsoleWrite("TimerInit: " & $iStart & @LF) ConsoleWrite("QueryPerformanceCounter: " & $iStart2 & @LF) Sleep(2000) ConsoleWrite(TimerDiff($iStart2) & @LF) ConsoleWrite((TimerInit() - $iStart2)*1000 / _WinAPI_QueryPerformanceFrequency() & @LF) Edited January 27, 2014 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Mat Posted January 27, 2014 Share Posted January 27, 2014 It's never actually documented what the return type is. It could change in the next release to something completely different, so any code you write that uses the return value for anything other than TimerDiff could be broken and it wouldn't even be mentioned in the changelog. That's why Valik said to treat it as a handle: something which only has meaning internally. BinaryBrother 1 AutoIt Project Listing Link to comment Share on other sites More sharing options...
czardas Posted January 27, 2014 Share Posted January 27, 2014 (edited) I agree with JohnOne. If it was not returning some kind of a time stamp, it simply could never work. It's irrelevant what data type is being used. Edited January 27, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
trancexx Posted January 27, 2014 Share Posted January 27, 2014 It's returning simple timestamp but read what Mat said, it sums it up perfectly. BinaryBrother 1 ♡♡♡ . eMyvnE 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