We have %ActionResult% now perhaps %ActionSeconds%?

We have a token called %ActionResult% but I'd like to see a token called %ActionSeconds% which returns "SECONDS()" for how long the action took. It should work on all actions (I suppose actions which run something asynchronously would return a low value.) It's such a common thing (for me) to have to measure how long an action takes.

If a person needed to examine both ActionResult and ActionSeconds, (a very rare situation) they would have to do that in a single statement, like this:

Actually, now that I think of it, it would be even better if KM supported both this feature, and a feature which cumulatively adds up the time spent by each action. That way I could look at each action in a macro (or each macro?) and see how much time was spent on it. That would help me optimize my programs. Here's a proposed example of what it could (theoretically) look like:

While not built-in, this is exactly how I use my multi-timer macro: I toss in a call wherever I need a task's timing split out, and it does all the work.

I've been using it a ton on the current project, and it's helped find chokepoints in my code. Built in would be great, but for now, this meets my needs. (I have a soon-to-post update that lowers the overhead even further, something like .015 seconds over a 25 second macro.)


1 Like

I doubt I would add specific support for this, since it's essentially equivalent to just:

  • Set Variable "LocalStart" to SECONDS()
  • Do stuff
  • Set Variable "LocalTimeTaken" to SECONDS()-LocalStart

Except that lets you decide exactly how you want to time what, you could have multiple points where you record the amount of time taken, etc, so it is far more flexible.

Yes, I understand, but I do have to have a separate global variable for every action that I want to track cumulative time for.