Jump to content

TimerInit() and TimerDiff() Problem


Recommended Posts

Hello,

I am having problems with accurate timings. I ultimately want to record the amount of time it takes for a window to appear following the entry of some data in another field (or another window closing). I have started with the sample script and am experiencing unexpected results.

for $i = 1 to 10
    $begin = TimerInit()
    sleep(3000)
    $dif = TimerDiff($begin)
    MsgBox(0,"Time Difference",$dif)
next

Results displayed in the MsgBox are:

1550.785

1035.364

1025.449

2285.864

917.707

849.383

996.170

1129.523

1377.241

924.231

Can someone explain please? I was expecting these results to hover around 3000. Thank you.

Link to comment
Share on other sites

  • Moderators

infinitr,

Welcome to the Autoit forum. :mellow:

I have just run your code and got these results, which are exactly as I (and you) expected:

3001.18206364217
3008.06890261192
3006.11146109352
3004.11427988753
3007.11766439589
3002.66660986243
3003.56134648398
3001.1143874431
3003.1131749985
3003.11080039502

Is there anything unusual about your system? Have you made any "unauthorised" adjustments to the CPU, for example? :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

Thank you. :)Been around before but it's been awhile and I guess I lost my login.

No I have not (hacked at the computer), but it has been running continuously for while. Let me try the old reboot and see what happens, being that from what I understand, the TimerInit(timestamp) is related to how long the system has been running. However, even if it works it would still wouldn't make a while lot of sense to me and would make me question reliability.

>>>>CTRL,ALT,DELETE

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Tell us which type of machine you're running that on: old laptop, recent 4-cores desktop, 4x 12-core server ...

Which system are you running?

Can you also try compiling that into .exe and set compatibility = W98. What do you get then?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Does this fix the problem?

Global $begin, $dif

$begin = TimerInit()

For $i = 1 To 10
    Sleep(3000)
    $dif = TimerDiff($begin)
    ConsoleWrite("Time Difference " & $dif & @CRLF)
Next
Link to comment
Share on other sites

Intel Core 2 Quad 2.66Ghz, Windows XP Pro sp3

The results of the script posted above are:

Time Difference 1376.37494755679

Time Difference 4161.99367222803

Time Difference 5596.52254043203

Time Difference 6603.26348222946

Time Difference 7675.32921406606

Time Difference 8515.08013924707

Time Difference 9502.69111059315

Time Difference 10404.5421162247

Time Difference 11406.1631987729

Time Difference 12394.4574431771

I still have to look into the other suggestions and report back....thank you.

Edited by infinitr
Link to comment
Share on other sites

  • Moderators

infinitr,

If you have Vista or Win7, right click on the .exe file and look under the "Compatability" tab on the properties box. You should see a "Compatability Mode" checkbox and combo - just check and select "Win98".

Your exe then runs as if under that OS - although I have no idea why jchd wants you to do so. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

W98 compatibility works the same for XP.

Digging around I read that this solves the issue for "some" chipsets/machines/drivers/OSses/WTF. Since it's easy to try and no risk, why not give that a chance?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...