LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

faster loops?

Hello,
 
while debugging one of my apps today, i tryed to understand why some repetitive while loop took so much time.
i made the short test below:
 
surprisingly, for a short For loop of 40M cycles, it takes about 5500ms to comlpete.
is it normal? sound to me extremely long, and it slows down my apps so much that i am at limit of functionality: if one wants to send info at 5MB/s, its just impossible.
 
now my apps itself is twice as long, because of actual computation done in the loop. and i do such loops (about 100Kcycles each) about 10K times...
 
Any idea? am i doing something basically wrong?

Message Edited by Gabi1 on 06-11-2007 10:14 AM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 1 of 6
(3,333 Views)
ok some more testing:
it is much faster without any computation in (in this case the time counter).
but any computation will slow the loop very very fast!
and this is yet without any array replacement, boolean switch...
 
 

Message Edited by Gabi1 on 06-11-2007 10:24 AM

Message Edited by Gabi1 on 06-11-2007 10:25 AM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 6
(3,328 Views)
Hi Gabi1,

that's natural: the more you compute the longer it takes Smiley Very Happy And ~1sec for 40-80 million additions (plus loop overhead) is quite ok.

It's not a good idea to put the 'Get time' function inside the loop, when you only need it outside of the loop. That's also true for any other function, but 'Get time' takes longer as it does some communication with the operating system (aka Windows).

You should also note which LabView version you use. Starting with LV8 the compiler is able to pre-compute 'constant' operations (like some of your loops) - so the compiling takes longer but in the runtime you don't need to compute all the values...

Message Edited by GerdW on 06-11-2007 10:29 AM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 6
(3,319 Views)
Hi GerdW
 
you are right about the get time. i was using it as a sim for actual operations in the loop. as i found out it dependant on system i took it out and made additions instead.
 
in any case, for an output data rate above the MHz, that makes loops not sufficiently fast.
having a computer at 2GHz, an addition at 40MHz plus overhead should still be way into the few tens of ms regime.
maybe i am expecting too much...
 
unfortunately i dont have "constant" operations those loops, since the data is actually calculated in them, whitout knowledge of previous state (for ex some boolean switch state).
 
 

Message Edited by Gabi1 on 06-11-2007 10:44 AM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 4 of 6
(3,303 Views)
Hi Gabi,

you want to calculate and output data with a rate of 40MHz on a 2GHz computer. This gives 2GHz/40MHz = 50. 50 clock cycles per iteration!
50 clocks to do calculation of data, provide loop overhead, do data communication with some devices, having OS activity in the background, and much more.
You surely expect too much (in my opinion). Even handcrafted assembler on a RT system should have problems to achieve this...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(3,296 Views)

GerdW,

yes you are probably right Smiley Happy

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 6 of 6
(3,222 Views)