LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to display execution time


@TechnoSam wrote:

This could be what I need if the problem is that it's so short of a time that it can't be measured. 


It is. In your example you're only performing a very small number of operations and it takes very little time to execute. There's no way you will be able to measure how long that takes with any accuracy.

 

What is that you actually want to measure?


___________________
Try to take over the world!
0 Kudos
Message 11 of 25
(1,280 Views)

I'm actually using Mac.

 

I replaced the timer functions with the High Resolution Relative Seconds.vi's but it didn't change anything. In fact, now when I run continuously, I don't even see the flickering that let me know something was going on...

I tried adding more decimal places again but that didn't change a thing, even when going through the debugger, it returned a whole number value when I formatted the output with "%.6f" into a string display.

 

I'm sorry I'm having so much trouble with this... I can't figure out why...

0 Kudos
Message 12 of 25
(1,278 Views)

[quote]

It is. In your example you're only performing a very small number of operations and it takes very little time to execute. There's no way you will be able to measure how long that takes with any accuracy.

 

What is that you actually want to measure?[/quote]

 

Just the execution time... I don't really know how else to describe it. I need to know which is faster and by how much of the two processes in the VI I attached. The Arithmetic or Function.

 

But even with the high resolution, it's still turning up 0.

0 Kudos
Message 13 of 25
(1,277 Views)

Hi Sam,

 

what happens with execution times when you run an operation for, let's say, a million times?

Do you think you will be able to compare timings then?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 25
(1,270 Views)

@TechnoSam wrote:
I need to know which is faster and by how much of the two processes in the VI I attached. The Arithmetic or Function.

Most likely the LV code is faster, but unless you're going to be calling it millions of times every second, the difference is negligble. To measure something like this, you would usually do something like calling it 10 million times in a loop, but that's when the optimizations I talked about can come into play and skew your results. If you want, you can look at the code of the express VI - you need to right click and select Convert to SubVI and then you will be able to look at the actual code.


___________________
Try to take over the world!
0 Kudos
Message 15 of 25
(1,264 Views)

Typically for something fast like this, I will put the code into a FOR loop and run it 100,000 to 1,000,000 times and just look at the total execution time.  I doubt you will see much difference between the two options.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 25
(1,268 Views)

tst wrote:

 If you want, you can look at the code of the express VI - you need to right click and select Convert to SubVI and then you will be able to look at the actual code.

Interesting enough, there's just a formula node in there with a case structure around it to not run when there's an error.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 17 of 25
(1,261 Views)

We are talking about the VI called "McFalls_Samuel_D2_7[Timer].vi", true?

 

There is a simple rule:

A subVI call adds overhead.

 

When running the code in a for loop 10M times, execution times start to differ at a measurable amount in favor for the "Arithmetic" setting. Everything with an elapsed time <10ms is near to worthless on Windows (and other non-deterministic) OSes. Since 10M iterations gives about 100ms (Function) and 70ms (Arithmetic), we are still very close to normal jitter of the OS. Still, it is save now to guess that the Function (ExpressVI) is about 20% slower than the Arithmetic ("primitives").

 

But as most already stated before:

Unless you are not calling the code many, many, maaaannnyyyyy times, the difference is really neglectable.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 18 of 25
(1,253 Views)

Ok, so it's working now, I'm running it at 10M loops. I'm still getting problems with the Hi Res function, its only returning whole numbers.

Using the millisecond timer now displays something that's actually worth seeing. I suppose that it's imposible for it to return anything but a whole ms value, right?

 

So my problem is in essence solved, but it's curious that I can't get decimal values of milliseconds out of the high resolution timer...

 

I can't decide which post to put the solution on, because it was a combination of posts that helped me make it work...

0 Kudos
Message 19 of 25
(1,251 Views)

First, you have to run it many times. Even with 10M iterations, you will see a big difference. So probably you want to increase the number of iterations to 50M or even >100M.

Second, the high resolution timer VI returns a double value representing the time in seconds. So replace both "tick count" functions in your benchmark with that function.

Additionally, your display element "Execution Time" is limited to 2 digits of precision. Increase that to somthing like 5.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 20 of 25
(1,243 Views)