Jump to content

TimerInit & TimerDiff limits / max value


Anne
 Share

Go to solution Solved by Melba23,

Recommended Posts

Hi everyone.

I have a question and wasn't able to find any answer for this.

What is the maximum value/limit for TimerInit & TimerDiff.

I mean, If I use TimerInit() in my script, how long can it 'last'? How long will I be able to read it with TimerDiff()?

I realize that the result of TimerDiff isn't an Integer. It's a floating number and I am not sure what the maximum value is.

I would like my program to use $Time = TimerInit() today, and then I'll be able to use TimerDiff($Time) tomorrow or even the day after. Is this possible? and what happens if TimerDiff exceeds the maximum value (if there is any)?

Link to comment
Share on other sites

TimerDiff returns the elapsed time in milliseconds calculated from a previous call to TimerInit. I can't test at the moment but I'm sure the result is an integer.
Use IsInt or IsFloat to check if it is an integer or a floating number.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If TimerInit uses the Kernel32.dll function QueryPerformanceCounter to calculate what values it gives, then it's probably about 68 years all the way up to 80,000 years according to this post I found. But a developer would need to answer this question as to how they obtain the values it uses.

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 Gude
How 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

 

I would like my program to use $Time = TimerInit() today, and then I'll be able to use TimerDiff($Time) tomorrow or even the day after. Is this possible? and what happens if TimerDiff exceeds the maximum value (if there is any)?

Just give it a try and you know if it works by tomorrow.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

TimerDiff returns the elapsed time in milliseconds calculated from a previous call to TimerInit. I can't test at the moment but I'm sure the result is an integer.

Use IsInt or IsFloat to check if it is an integer or a floating number.

 

Well I know that it isn't an Integer. Because after 1 second has elapsed, the result of TimerDiff would be something like 1000.48243

Which is why I asked what the maximum value of a floating number would be.

 

If TimerInit uses the Kernel32.dll function QueryPerformanceCounter to calculate what values it gives, then it's probably about 68 years all the way up to 80,000 years according to this post I found. But a developer would need to answer this question as to how they obtain the values it uses.

 

Very good reply! Now, is it possible for a floating number to hold that value in milliseconds? I mean, that would be "2144448000000" milliseconds.

Just give it a try and you know if it works by tomorrow.

 

Yea I am already testing this, but I asked because what happens if I let it wait 2 days, 3 days, 1 week etc. It would take forever to get the answer by testing it.

Link to comment
Share on other sites

  • Moderators

Anne,

TimerInit/Diff should generally only be used for measuring relatively small time periods. If you are looking to determine delays of "2 days, 3 days, 1 week etc" I would recommend using either DateDiff on suitable DTG strings or (if accuracy is not that necessary) the various date/time macros that you can find in this list. :)

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

Anne,

TimerInit/Diff should generally only be used for measuring relatively small time periods. If you are looking to determine delays of "2 days, 3 days, 1 week etc" I would recommend using either DateDiff on suitable DTG strings or (if accuracy is not that necessary) the various date/time macros that you can find in this list. :)

M23

 

I had actually considered this as a solution but after giving it some work I realized that I couldn't make it accurate enough.

Say I want the script to perform a certain task 75½ hours after it has been executed.

Or exactly 24 hours (+/- 1 min) after execution.

In practise, I will need it to measure anything from 5 mins to a few days, which is why I'd prefer TimerInit/TimerDiff. However, it could be possible to use both solutions along each other.

I guess I will just have to try working with the Timer functions untill I (maybe) hit a natural wall and then move on to DateDiff for some of the timing instead.

Link to comment
Share on other sites

  • Moderators
  • Solution

Anne,

 

perform a certain task 75½ hours after it has been executed. Or exactly 24 hours (+/- 1 min) after execution

The macros are perfectly suitable for that. Just poll them at a suitable interval - say 1 hr intervals for 23 hours, then 1 min intervals until 23:59, and finally 1 sec intervals until you reach the correct moment. :)

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

Anne,

 

The macros are perfectly suitable for that. Just poll them at a suitable interval - say 1 hr intervals for 23 hours, then 1 min intervals until 23:59, and finally 1 sec intervals until you reach the correct moment. :)

M23

 

I must have been drunk since I did not think of this.

That's perfect thanks M23!

Link to comment
Share on other sites

  • Moderators

Anne,

Glad I could help. :)

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

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

×
×
  • Create New...