LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How much is a char in a string

I found a faster code. Smiley Happy (with assembler and a call dll library)

Search one character or a substring in a string
Methods : SpreadSheet,  Replace, Count .... and ASM_DLL

(Count method works only to search one character)

"ASM_DLL method" works for both cases, one character or a substring

attached file : Benchmark

 

string 50e6 characters


substring : "abc"


  • SpreadSheat - 504ms

  • Replace - 428ms

  • Count - doesn't work if more than one character

  • ASM_DLL - 71ms

only one character : "a"


  • SpreadSheet - 639ms
  • Repalce - 435ms
  • Count - 102ms
  • ASM_DLL - 78ms

 

 

0 Kudos
Message 11 of 27
(1,239 Views)

Well, in all LabVIEW coding challenges so far, external code, such as DLLs are not allowed.

 

I would never doubt that a hand-coded dll will be faster and I am happy that LabVIEW is within 25% of its speed. That should tell you something.

 

Don't forget that most computers have multiple cores and LabVIEW would easily allow this problem to be split onto multiple parallel cores. We should be able to get 4x faster on a quad core CPU, easily beating your dll (which of course could also be adapted for multiple cores). 😄

0 Kudos
Message 12 of 27
(1,232 Views)

OK, here's a quick "pure LabVIEW" draft that easily beats your dll.

 

  • 262ms: Spreadsheet (9.0x of fastest)
  • 225ms: Replace 7.8x of fastest)
  • 56ms: count (1.9x of fastest)
  • 43ms: ASM_DLL (1.5x of fastest)
  • 29ms: parallel Count (8 instances). fastest!

The first four versions use about 12% CPU (I7-2600K) while the parallel version uses 30% CPU. There might still be room for improvement. This is just a 2minute modification of the existing code, I am sure it could be tuned more. 😉

 

Download All
Message 13 of 27
(1,224 Views)

Q6600 core2 quad

 

ASM_DLL - 78ms

Parallel count - 73ms (congratulation altenbach)

 

8 instances ... woaw !

i see a "P" in your For Loop ... i don"t know this "P" (??) ...

how do that ? From where comes this "P" Smiley Frustrated  Smiley Embarassed

 

 

 

0 Kudos
Message 14 of 27
(1,217 Views)

right-click the FOR loop...configure iteration parallelism.

 

See also this page, for example.

 

Of course nothing prevents you from placing your dll in a parallel FOR loop, now you are done in 25ms on my computer. 😄

 

 

 

Message 15 of 27
(1,215 Views)

ok, thank you altenback

 

... hummmm ... I don't admit defeat!   Smiley Happy    i will be back....  Smiley Wink

0 Kudos
Message 16 of 27
(1,209 Views)

@ouadji wrote:

 i will be back....  Smiley Wink


See my edit in the reply above. 😄

0 Kudos
Message 17 of 27
(1,206 Views)

 

woaww ... beautiful !!!


you go too fast  Smiley Happy ... altenback, the knight of LV ... yes, i agree, really.

 

0 Kudos
Message 18 of 27
(1,200 Views)

 

on my computer (Q6600 4 core - 2,4Ghz)

 

before 78 ms (26% cpu) ==> after 62 ms (69% cpu)

 

again, thank you ... Altenbach

a good day today, I learned something new! ("P")  Smiley Happy

 

original5.png

0 Kudos
Message 19 of 27
(1,188 Views)

multiple instances will not work with a substring (not only one character)
impossible to cut the string without risking a split in a substring

 

and in this case ... my dll will give the best result    Smiley Wink

0 Kudos
Message 20 of 27
(1,179 Views)