05-14-2013 03:47 PM - edited 05-14-2013 03:55 PM
05-15-2013 03:22 PM - edited 05-15-2013 03:26 PM
@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:
...Darin's Version only takes ~1/4 in comparison to altenbach's approach, see:
2# second benchmark
BUT when I use a Control-Element like this:
... altenbach's piece of code is way faster than Darin's approach, see:
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
05-15-2013 03:26 PM - edited 05-15-2013 03:29 PM
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.
05-15-2013 03:29 PM
@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!
05-15-2013 04:28 PM
A few more things about benchmarking:
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....