05-27-2010 06:15 AM
On occasion, you may wish to measure the amount of time a certain piece of code takes to execute.
What many people do is something like one of these options:
But this annoying to rewrite every time. If you're good, you probably have a merge VI or use VIs such as the OpenG VIs shown here to save some time on writing this code.
Well, there is a faster way:
The timed sequence has an output terminal which tells you how long it takes to execute. You can simply drop one and select that terminal.
Caveats:
For a list of past nuggets, see here.
05-27-2010 06:32 AM
Some minor bugs:
* We already have the year 2010
* In the first pic (flat sequence), the inputs of the substract-prim needs to be swapped (as in the code using OpenG)
Anyway, thanks for the community nugget.
Felix
05-27-2010 07:56 AM
F. Schubert wrote:
We already have the year 2010
Do we? Well, what can I say, I'm a retro kind of guy.
In the first pic (flat sequence), the inputs of the substract-prim needs to be swapped (as in the code using OpenG)
Actually, in both cases the earlier time is correctly substracted from the later time. It's just arranged differently (and I agree it can be confusing. Another reason to do this, although personally I don't time my code very often, so I don't actually use this).
05-27-2010 01:16 PM
In the first pic (flat sequence), the inputs of the substract-prim needs to be swapped (as in the code using OpenG)
Actually, in both cases the earlier time is correctly substracted from the later time. It's just arranged differently (and I agree it can be confusing. Another reason to do this, although personally I don't time my code very often, so I don't actually use this).
Sequences always make me nervous...
So I prefer negative times for two reasons:
* Something odd is on my BD
* Rewind the time ASAP before the moment I dropped the sequence
Felix
05-27-2010 04:17 PM - edited 05-27-2010 04:17 PM
05-29-2010 01:45 PM
06-07-2010 03:49 PM
Nice trick. I'm not sure if it is as accurate, but I usually use a custom probe to accomplish this. That way you can do timing checks without changing your code. My version keeps track of your worst timing cycle.
I have attached the error cluster version of the probe that you are free to use. You will need to create a new version for different data types. All probes use the same notifier to communicate, so you can use two probes of different data types to time a single operation.
do you think this is a good way to accomplish this?
06-07-2010 05:05 PM
06-08-2010 01:37 AM
I forgot to metion the probe method because I was focusing on getting that off my mind.
You are correct that the probe method has a great advantage in that you don't need to change the code, but it also has some disadvantages: