Miranda Posted July 28, 2008 Posted July 28, 2008 Hi everyone Well, so here's my problem:Timerinit() returns a timestamp, to me it seems a strange timestamp, lookie here: 706'850'139'146'652 (digit grouping added for emphasis), now, since the function states it returns a timestamp in milliseconds, I would assume we are talking about something in the region of 22'414 years worth of milliseconds... however, a bit later the timestamp is now 727'289'493'116'814, and the diff between those two is 6'799'518.94773952. okay, so it's not actually 22'414 years, but 2 hours, which means the timestamp returned is NOT in milliseconds but in 10s of nanoseconds (if I counted correctly). Now, I don't know about your machine and OS, but mine is not even remotely capable of timings this accurate.I just thought of a funny use... measure the time loss of a certain procedure:this code:Global $a[3] $c=Timerinit() $c1=Timerinit() $c2=Timerinit() _log($c) _log($c1) _log($c2) For $b=1 to 3 $a[$b]=timerinit() Next For $b=1 to 3 _log($a[$b]) Next For $b=1 to 3 _log(Timerinit()) Next Func _Log($text) $file = FileOpen(@ScriptDir & "\log2.txt", 1) FileWriteLine($file, $text) FileClose($file) EndFunc ;==>_LogProduces this: 9242865200448 9242865208206 9242865211410 9242866757412 9242866762038 9242866765602 9242867654415 9242867881575 9242868156408Which could teach us that, if we required something to go off at a precision of ~60 microseconds, arrays are fine, no visible difference to normal variables (oh, a for loop aswell), but stay away from opening, writing to and closing files!Sooo... thats one part of the timerinit thing I never liked, seriously, millisecond accuracy is more than enough!However, my real problem is this: Timerinit() seems to restart/go fubar if you reboot your machine, since I have a script which writes timerinits to .ini files, reboots, rereads them and then comes up with: 748096569011160 (before reboot), 9406684172880 (after reboot) and -245738484.648802 (the difference), this is a problem if it waits for a difference of 6835000.Now, I know my options are to calculate the seconds myself (which would be accurate enough for my purposes... hell, minutes would be!), using @year @yday @hour @min and @sec, but... you know, couldn't we change the Timerinit() to 1) milliseconds and 2) Time difference between the now and.. 1 Jan 2000 for example?As far as I can see, as long as we change TimerDiff() along with it to expect milliseconds instead of 1/100ths of microseconds no changes in any existing scripts would be required and it should stay backwards compatible. The drawback of course would be that we no longer get such an exact readout...I hope I don't come over wrong, this should be a kind of suggestion, or make you think, or even smile for a few seconds, not an OMGBBQWTF-rant Oh, I should add that I found nothing in bug reports, and well, I don't consider this a bug, merely a ... flaw, if you will, so I'd first like to hear some input, and I'd more than happily fill out a bug tracking thingy if the responses are positive Kind regards,Miranda
Moderators SmOke_N Posted July 28, 2008 Moderators Posted July 28, 2008 (edited) If you want to read up on how TimerInit() works, http://msdn.microsoft.com/en-us/library/ms644904(VS.85).aspx , you'll need to understand how that works first. (You'll see that it is basically a counter from the time that the system was rebooted.)So you'll see that TimerInit() works exactly how it should, and how many other languages in fact use it as well.Edit:*Had a thought*If something like that is that important to you, I'd do my homework maybe on how to retrieve the bios time, which wouldn't reset on reboot. Edited July 28, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Miranda Posted July 28, 2008 Author Posted July 28, 2008 (edited) Hey Smoke Thanks for your answer... I do understand how timerinit works. Or rather, I didn't at first, and I looked at what was happening and the numbers I got, and I realized how it worked (and the resolution returned made me understand that this is an "external" function... I've run into timers on windows and problems with them when I had some SERIOUS DPC Latency trouble) Also, I do not doubt that it is working as intended, nor do I doubt that many other languages use it like this, but I was trying to point out (from a pure user standpoint of view, I'm not a dev at any rate, merely an autoit scripter), that the way it works doesn't make much sense, since, imho there is a much simpler alternative of calculating the ms since a certain date. Hmm, and no, this has been a bit of a peeve to me since I started scripting autoit, yet this instance is the very first time that I'm actually having trouble with it, instead of just being annoyed by the way it works , yet, like I said, I can code around it without much trouble, so there's no need to... bios time? oh boy Simply windows time difference to a certain date in the past would be idea imho. So, this was simply a "I don't like how it works, and have a suggestion as to how it should work, and would like to hear other peoples opinions" kind of thread... Kind regards, Miranda Edit: Spelling, Logic, etc. Edited July 28, 2008 by Miranda
Moderators SmOke_N Posted July 28, 2008 Moderators Posted July 28, 2008 Hey Smoke Thanks for your answer...I do understand how timerinit works. Or rather, I didn't at first, and I looked at what was happening and the numbers I got, and I realized how it worked (and the resolution returned made me understand that this is an "external" function... I've run into timers on windows and problems with them when I had some SERIOUS DPC Latency trouble)Also, I do not doubt that it is working as intended, nor do I doubt that many other languages use it like this, but I was trying to point out (from a pure user standpoint of view, I'm not a dev at any rate, merely an autoit scripter), that the way it works doesn't make much sense, since, imho there is a much simpler alternative of calculating the ms since a certain date.Hmm, and no, this has been a bit of a peeve to me since I started scripting autoit, yet this instance is the very first time that I'm actually having trouble with it, instead of just being annoyed by the way it works , yet, like I said, I can code around it without much trouble, so there's no need to... bios time? oh boy Simply windows time difference to a certain date in the past would be idea imho.So, this was simply a "I don't like how it works, and have a suggestion as to how it should work, and would like to hear other peoples opinions" kind of thread... Kind regards,MirandaEdit: Spelling, Logic, etc. Ahh, then I'll move your post to the official Devs bitch section since it wasn't a question for support or a lack of undestanding Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Miranda Posted July 28, 2008 Author Posted July 28, 2008 Ahh, then I'll move your post to the official Devs bitch section since it wasn't a question for support or a lack of undestanding Thanks alot!I was a bit afraid to post here, since I'm not really experienced or established enough
weaponx Posted July 28, 2008 Posted July 28, 2008 There was a lengthy, semi-informative discussion about this recently:http://www.autoitscript.com/forum/index.ph...mp;hl=timerdiffClearly TimerInit() relies on a "time since boot" metric so I would have never considered storing it for later use.
Miranda Posted July 28, 2008 Author Posted July 28, 2008 Thanks for that link, rather informative... What do you have to say on the subject, should timerinit be changed to allow storing and reloading after boot, or is it handy as a counter to find out the time since last boot?
monoceres Posted July 28, 2008 Posted July 28, 2008 (edited) Hi!I made a simple dll you can use, it's simply returning the amount of seconds since 1/1-1970http://monoceres.se/Uploads/time.dllYou can call it like this:$data=DllCall("time.dll","int:cdecl","GetPOSIX") MsgBox(0,"Seconds since 1/1-1970",$data[0]) Edited July 28, 2008 by monoceres Broken link? PM me and I'll send you the file!
Richard Robertson Posted July 28, 2008 Posted July 28, 2008 You could use the date functions if you don't need super accuracy.
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