Author Topic: Measure command time  (Read 9574 times)

BlackJack

  • Jr. Member
  • **
  • Posts: 68
Measure command time
« on: July 24, 2016, 06:44:58 AM »
Some of my macros are including some text reading and editing functions.
I want measure the time, a command needs to finish. The most obvious method would be to use the date tokens.
But I don't know how to calculate the time difference between date tokens and get a 'human readable' result like 0.5 sec .

Has someone experiences with such things? Thanks in advance.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Measure command time
« Reply #1 on: July 24, 2016, 12:09:21 PM »
Try this:
Code: [Select]
Set date [StopWatch] value to the current date/time
Set decimal [StopWatchEnd] value to the converted value of {EXP:({DATETICKS} - {DATETICKS:StopWatch}) / 10000000} (round to 2 decimal places)
Write '[Purple] StopWatch: {DEC:StopWatchEnd} Seconds' to log

I can't test it because of a bug(the report of which has apparently vanished), but it should work on most locales.

You could set a text value, rather than a decimal, but then it'll give you results like "StopWatch: 0,1600002 Seconds", as it won't be rounded down.


You don't have to use a date value if you don't have to modify the start time, so you could use:
Code: [Select]
Set decimal [StopWatch] value to the converted value of {DATETICKS}
Set decimal [StopWatch] value to the converted value of {EXP:({DATETICKS} - {DEC:StopWatch}) / 10000000} (round to 2 decimal places)
Write '[Purple] StopWatch: {DEC:StopWatch} Seconds' to log

BlackJack

  • Jr. Member
  • **
  • Posts: 68
Re: Measure command time
« Reply #2 on: July 24, 2016, 01:42:00 PM »
Thanks Pfeil.

I'll try both and see what's better, when I'm at home again...

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Measure command time
« Reply #3 on: July 24, 2016, 09:06:03 PM »
Quote
I can't test it because of a bug(the report of which has apparently vanished), but it should work on most locales.


http://voiceattack.com/SMF/index.php?topic=202.0

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Measure command time
« Reply #4 on: July 24, 2016, 09:21:03 PM »
Quote
I can't test it because of a bug(the report of which has apparently vanished), but it should work on most locales.


http://voiceattack.com/SMF/index.php?topic=202.0

Quote
An Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you.

I knew I wasn't crazy! Well, just a little.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Measure command time
« Reply #5 on: July 25, 2016, 12:02:34 AM »
DOH!  I need to fix that.  It's in there, though :)

BlackJack

  • Jr. Member
  • **
  • Posts: 68
Re: Measure command time
« Reply #6 on: July 26, 2016, 02:14:22 AM »
Quote
I can't test it because of a bug(the report of which has apparently vanished), but it should work on most locales.

I'm also affected by this (very old  ;D ) bug. I can't round the value. But it was still very helpful. Thanks

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Measure command time
« Reply #7 on: July 26, 2016, 03:46:00 AM »
I'm also affected by this (very old  ;D ) bug. I can't round the value.
Aha. "Good" to know I'm not alone in this, in a weird way.

I do remember having a workaround:
Code: [Select]
Set date [StopWatch] value to the current date/time
Set decimal [StopWatchEnd] value to the converted value of {EXP:{DATETICKS} - {DATETICKS:StopWatch}}
Set decimal [StopWatchEnd] to [StopWatchEnd] divided by 10000000 (round to 2 decimal places)
Write '[Purple] StopWatch: {DEC:StopWatchEnd} Seconds' to log
As long as the input is an integer(which it will be in this case, as both tick values are), the conversion works fine, so you do the division after the fact.

Even if your input was non-integer, you could use
Code: [Select]
Set decimal [StopWatchEnd] value to the converted value of {EXP:(5 / 2) * 10000}
Set decimal [StopWatchEnd] to [StopWatchEnd] divided by 10000
To shift the decimal point to make it integer, and then undo the shift once the value is set.

BlackJack

  • Jr. Member
  • **
  • Posts: 68
Re: Measure command time
« Reply #8 on: July 31, 2016, 09:45:32 AM »
Thanks for all the options, that you have figured out.
I like it simple and clean. So, this is my favorite:
Code: [Select]
Set date [StopWatch] value to the current date/time
Write '[Purple] {EXP:({DATETICKS} - {DATETICKS:StopWatch}) / 10000000} sec' to log
I wasn't aware, that I only have to divide the Dateticks by 10000000 to get the value in seconds. ::)

What I have found, is that VA [1.5.12] is getting incredibly slow after a reboot.
A special command needs more than a second (1.3) to finish. Everything feels very laggy overall.
What helps, is to reinstall VA and the same command needs only 0.2 seconds and VA feels much more responsive again.

Aha. "Good" to know I'm not alone in this, in a weird way.

Everyone, that uses a comma as decimal separator, should be affected.
But it seems, that the decimal tokens are not used very often.
« Last Edit: August 01, 2016, 11:06:11 AM by BlackJack »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Measure command time
« Reply #9 on: July 31, 2016, 05:06:41 PM »
Quote
What I have found, is that VA [1.5.12] is getting incredibly slow after a reboot.
A special command needs more than a second (1.3) to finish. Everything feels very laggy overall.
What helps, is to reinstall VA and the same command needs only 0.2 seconds and VA feels much more responsive again.

So, same VoiceAttack.dat and same user.config settings but a, 'fresh' .exe solved the speed problem?  If that's the case, something happened to your .exe as .exe's usually don't go stale as far as I can recall o_O

BlackJack

  • Jr. Member
  • **
  • Posts: 68
Re: Measure command time
« Reply #10 on: August 01, 2016, 11:01:10 AM »
I'm not sure, if the VA.exe is the reason, but that's what I could observe...
And it is reproducible. The strange thing is, after a period of time the issue is gone by itself.
But reinstall VA helps immediately. I can install an earlier iteration and see if happens the same..