Jump to content



Photo

TimerInit(), Int versus Float. (?)


  • Please log in to reply
11 replies to this topic

#1 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 30 September 2011 - 08:23 AM

I wonder why TimerInit() is returning a Float instead of a Int.

As: Windows, as in 'QueryPerformanceCounter', is returning it as a Int. (LARGE_INTEGER)

So:
If AutoIt is not using 'QueryPerformanceCounter' to get the target value. What is it using? (or: additional info on reason(s) for it to be a float)

If AutoIt is using 'QueryPerformanceCounter' ... The only thing that makes sense to me here is that TimerInit() was implemented before 64bit value support where implemented. (in which case the question comes down to 'why not update TimerInit() to make use of the 64bit value support.)

As Valiks closing comment on ticket 2008 seems to be related to TimerDiff() (which was not the subject of the ticket) its not helping in this matter.

The general benefits would be minor. Seemingly more consistency in the returned TimerInit() data(type) in relation to windows 'QueryPerformanceCounter' and a little speedup in special AutoIt timer scripts. (Int versus float math. ... assuming of course.)

Ticket: #2008
MSDN: QueryPerformanceFrequency

Edited by iEvKI3gv9Wrkd41u, 30 September 2011 - 08:26 AM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"





#2 Manadar

Manadar

    Taking a REST.

  • MVPs
  • 10,714 posts

Posted 30 September 2011 - 11:51 AM

In the v3.1.0 download of the AutoIt source code, the function TimerInit is in src/script_misc.cpp. It uses QueryPerformanceCounter on a __int64 and converts that to double. There are no documented changes in the History page for TimerInit/TimerDiff after 2004.

Edited by Manadar, 30 September 2011 - 11:53 AM.


#3 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 30 September 2011 - 03:04 PM

aha, thanks.

Additional data: (pulled from online beta history)

3.1.0 (7th February, 2005) (Release)
- Changed: (Internal) Variant rewrite (now handles int32, int64, double, string, HWND data)

3.0.102 (4th August, 2004) (Release)
- Changed: TimerStart() renamed to TimerInit(). TimerStop() renamed to TimerDiff()

3.0.70 ... (last date on: v3.0.75 (30th November, 2003))
- Added: TimerStart(), TimerStop()

So it seems as I anticipated. ... :graduated:

Edited by iEvKI3gv9Wrkd41u, 30 September 2011 - 03:08 PM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#4 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 02 October 2011 - 07:42 AM

Added it as Request to tracker. #2025
Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#5 trancexx

trancexx

    Hm, I really shouldn't.

  • Active Members
  • PipPipPipPipPipPip
  • 5,187 posts

Posted 02 October 2011 - 02:50 PM

VarGetType is great when used with sense. Used otherwise makes normal people wish it wouldn't exist at all.

eMyvnE


#6 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,825 posts

Posted 02 October 2011 - 06:41 PM

I'm not sure if this would be of any help in understanding what the timer functions are returning, but this article might help explain why it comes back as an float rather than an int.

The value retrieved is an integer, but that's meaningless unless you know what the frequency of the counter is. The returned counter will give you a figure of how many ticks it counted, take that number and divide it by the ticks per second (the frequency) to get the time, this value is going to be a float.

Edited by BrewManNH, 02 October 2011 - 06:41 PM.

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#7 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 02 October 2011 - 06:57 PM

From the ticket I just closed:

If you use the return value from TimerInit() for anything other than an opaque handle to be passed to TimerDiff() then you are asking for trouble. Therefore the type is irrelevant. Ticket closed.


Edited by Valik, 02 October 2011 - 06:57 PM.


#8 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 02 October 2011 - 09:25 PM

Your closing it based on a presumption how I (or others) might be (mis)using it ?
(I personally don't even use TimerDiff() in the case where I work directly with the TimerInit() data.)

Would have been nice if you could have used one of the reasons I mentioned for the closure reason ...

The general benefits would be minor. Seemingly more consistency in the returned TimerInit() data(type) in relation to windows 'QueryPerformanceCounter' and a little speedup in special AutoIt timer scripts. (Int versus float math. ... assuming of course.)

But than I probably should have included them (as text) in the ticked if I read you right.

O well.

Edited by iEvKI3gv9Wrkd41u, 02 October 2011 - 09:28 PM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#9 Beege

Beege

    Universalist

  • MVPs
  • 843 posts

Posted 03 October 2011 - 12:36 AM

Your closing it based on a presumption how I (or others) might be (mis)using it ?

I dont think its just that. Your asking them to change two functions for something that you even said "the benifits are minor". Plus since you can use DllCall() and 'QueryPerformanceCounter', theres already an alternative to using the autoit timer functions. Asking them to make changes that produce minor benifits and already has alternatives, is sure to get shot down.

#10 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 03 October 2011 - 02:01 AM

I closed it because it's a fucking stupid request. You are trying to attach meaning to the return value of TimerInit() that we do not guarantee. The return value of TimerInit() should be treated as an opaque handle. That means the underlying type is irrelevant. If I want to make it a string that's my choice as a developer of AutoIt. All I have to ensure is that TimerDiff() still accepts that data and that TimerDiff() returns the calculated difference. There are no other guarantees about how either function works.

I'm going to go adjust the documentation accordingly. Now shut the fuck up about this absolutely stupid and pointless subject.

Edited by Valik, 03 October 2011 - 02:04 AM.


#11 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 03 October 2011 - 02:36 AM

Now shut the fuck up about this absolutely stupid and pointless subject.

Yea yea, I know, or else you just ban me for amusing you to much.

[Left topic.]
Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#12 wraithdu

wraithdu

    I am less fun than a twisted ankle.

  • MVPs
  • 2,137 posts

Posted 03 October 2011 - 02:43 PM

FYI, if you need a guaranteed return type, use _Timer_Init() and _Timer_Diff() from Timers.au3. They are wrappers for QueryPerformanceCounter and Init returns an int64.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users