LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to display execution time

This is a pretty open ended question... How would you display the amount of time that code took to execute? Like, just start a timer when the program starts and end the timer when it terminates. I've done about an hour of research, and I really can't find anything that will display it to the user. (I know execution time can be found under Tools > Profile > Performance and Memory)

 

Any help would be appreciated.

0 Kudos
Message 1 of 25
(5,146 Views)

@TechnoSam wrote:

This is a pretty open ended question... How would you display the amount of time that code took to execute? Like, just start a timer when the program starts and end the timer when it terminates.


The most common method is a simple three frame sequence structure.

 

You know what, just read this - http://forums.ni.com/t5/LabVIEW/Community-Nugget-05-27-2009/m-p/1137228#M501103

 

 

P.S. Measuring timing may not give you what you want. There are all kinds of things which can affect how long a piece of code takes to execute. From pre-computed values to hardware optimizations to parallel executions to other programs running in parallel to low memory conditions to already allocated memory and so on.

 

The main question is whether you're trying to optimize your code or just tell the user "look, this took 4 minutes".


___________________
Try to take over the world!
0 Kudos
Message 2 of 25
(5,142 Views)

All I want to do is say "Look, this took x amount of time."

 

I couldn't make any sense of that link, it was basically a picture with no instructions, so I couldn't replicate it. Could you explain it to me?

0 Kudos
Message 3 of 25
(5,128 Views)

Place 2 Tick count, before and after your main code. The difference is the time needed.

You might need to place them in a sequence structure to control execution time.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 25
(5,107 Views)

Drop a flat sequence structure around the code and add frames to it. The first and third frames should have Get Date/Time in Seconds and the second should have your code. Then, just subtract the values and you will get the number of seconds.


___________________
Try to take over the world!
0 Kudos
Message 5 of 25
(5,102 Views)

It appears to be working, but it's not accurate enough. I always get zero when I do a single execution, and it looks like it's flickering between zero and 1. When I debug, I get something like 5 or 6 seconds, which seemed to be about the time it took for me to go through the code.

 

I tried adding a format string command to change the number of decimal places in case it was taking less than 1ms to execute, but it didn't change anything. I suppose that 1ms must be the smallest increment that the timer measures. But is that even realistic? I thought that it was a rule of thumb "1 line of code = 1ms of execution time." I do have a pretty simple program here, but I didn't think it'd be THAT simple.

 

Can anyone take a look at it and see why it's just displaying zero?

0 Kudos
Message 6 of 25
(5,086 Views)

You could use

C:\Program Files\National Instruments\LabVIEW 2012\vi.lib\Utility\High Resolution Relative Seconds.vi

for better resolution.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 7 of 25
(5,082 Views)

How do I use that? Normally I would guess copy/paste from the block diagram, but it's blocked by a password... I am using a legitimate version of LabVIEW that I purchased, not a cracked copy.

 

Can you tell me how I would use that in my VI?

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

0 Kudos
Message 8 of 25
(5,079 Views)

Just drag and drop it on to your block diagram. Use it as a subVI. NI has locked it, its nothing to do with your LEGITIMATE version of LabVIEW!

 

If it is a very short time you cannot be sure of the timing as it can depend on windows tasks and other caveats. (assuming you do use windows)


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 9 of 25
(5,070 Views)

Maybe the attached tictoc.vi helps a bit with the room on the block diagram. Feel free to exchange the normal ms-timer with the suggested HiRes one.

0 Kudos
Message 10 of 25
(5,064 Views)