LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop and structure performance

HI!

I am trying to compare performance between using loop or case structure to wait for an user action, the two route are the images attched:

 

Looking at file size:

 

Structure.exe = 180KB

loop.exe = 178

 

Looking at the task manager:

 

Loop.exe have on CPU 24-25 constant and memory 16,176K (If I add a "Wait (ms) Function" with 200 ms it down CPU to 00-02 )

Structure.exe on CPU 00 and memory 16,152K

 

One thing I have noticed when I click on yes that will stop the application the CPU does not change from 00 (surely it use it to execute the case, right?)

 

What other way of tool could I bench mark this type of test and what other parameters should I be looking at?

 

What is the different of both approaches in terms of compile code?

 

Download All
0 Kudos
Message 1 of 5
(2,621 Views)

Why are you running this benchmark?

 

This might give you more information.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 5
(2,611 Views)

No need to bench mark.  Use the event structure, it is there so polling isn't necessary.  Polling is in most cases an old and busted way of doing things before the event structure was made.  This was something like 12 years ago so no modern code should use this method unless there is good reason to.  Your polling method will starve a CPU to 100% (usually) for doing no useful work.

0 Kudos
Message 3 of 5
(2,607 Views)

Just to get one thing right, your "case structure" is NOT a Case structure, but an Event Structure. 

 

So you are doing a test of polling and events? But why? 

And with a while loop without any wait in it, taking all the cores process power? 

0 Kudos
Message 4 of 5
(2,564 Views)

You probably have a 4 core computer which is why you are see 25% usage.

 

If you put a tiny wait statement in that loop, even a 0 msec wait, will allow the CPU time to do other things.

 

What you have is called a "greedy" loop or a CPU burner because it is mainly trying to run as fast as it can heating up the CPU to do basically nothing.

 

The event structure is the best way to go.  But the polling loop is okay as long as you put a wait statement in it.  Even a bit larger wait like 100 or 250 msec would seem to be super responsive to the normal user.

0 Kudos
Message 5 of 5
(2,550 Views)