LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace series of 0s with one 0


@Darin.K wrote:

(0|1)\1{0,3}(\1?+)(\1{0,2})


This is one of the reasons I became a graphical programmer. 😄

 

( I am typically not dyslexic, but here it suddenly kicks in... 😮 )

 

All we need now is a solution in APL. 😉

Message 21 of 25
(747 Views)

@zerotolerance wrote:

@altenbach wrote:

Here's a non-regex solution. 😄 

 


Any advantages over the regex from Darin? Is it something to do with memory/speed/performance?  Just curious.


dear forum,

 

 

I was curious as zerotolerance, so I actually did a benchmark and here are my results which I'd like to discuss with you, because I'm puzzeled:

 

I run both pieces of codes 1024 times and measure the ellapsed time using a sequence structure.

 

1# first benchmark

 

When I use a string constant, like this:

 

version1-blockpanel.png

 

 

...Darin's Version only takes ~1/4 in comparison to altenbach's approach, see:

version1-graph.png

 

 

2# second benchmark

 

BUT when I use a Control-Element like this:

version2-blockpanel.png

 

 

 

... altenbach's piece of code is way faster than Darin's approach, see:

version2-graph.png

 

 

Morover, altenbach's approach seems to be consistent in terms of the time elapsed.

 

Why is Darin's approach reacting so different to this little change: string constant --> string control ?

 

 

 

 

Regards,

Alex

 

Download All
0 Kudos
Message 22 of 25
(714 Views)

Diagram constants can cause constant folding, meaning the compiler calculates the result once at compile time and never again, because it know that things can never change later. (See also)

 

In general, correct benchmarking is an art and you need to be aware of many such details.

Message 23 of 25
(710 Views)

@altenbach wrote:

Diagram constants can cause constant folding, meaning the compiler calculates the result once at compile time and never again, because it know that things can never change later.


thank you!

0 Kudos
Message 24 of 25
(703 Views)

A few more things about benchmarking:

 

  • Don't place front panel terminals in innermost loops. They use significant efforts, blurring the pure algorithm time. (even the "live beat" updates asynchronously and might intefere with the algorithms on a single core machine)
  • Wiggle the input a bit with each iteration to avoid folding ( I use rotate string, probably not optimal)
  • Disable debugging
  • You only need one ticker in the middle frame.
  • use high resolution relative seconds for sub-ms resolution. (from vi.lib/utility).
  • Use log scale if the plots differ by orders of magnitude

I would also use much longer string instead of many iterations in short strings. (not shown)

 

Here's a very quick modification. Probably needs a bit more work but should give you some ideas....

Message 25 of 25
(692 Views)