in reply to Re^2: Vowel search
in thread Vowel search
Well, if we're micro-optimizing, then either we want to do this…
[AaEeIiOoUu][AaEeIiOoUu]…instead of this…
[AaEeIiOoUu]{2}…or we want to rewrite the program in C.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Vowel search
by AnomalousMonk (Archbishop) on Jun 11, 2014 at 22:47 UTC | |
There doesn't seem to be a significant difference between the [AaEeIiOoUu]{2} and [AaEeIiOoUu][AaEeIiOoUu] variations under Strawberry 5.14.4, but I was a bit surprised that there's so little improvement over the /i version.
The results are closer to what you suggest under ActiveState 5.8.9, but with /i still surprisingly high.
Still, as you say, it's a bit of a micro-optimization. | [reply] [d/l] [select] |
by tye (Sage) on Jun 12, 2014 at 01:43 UTC | |
It is too bad that people posting "benchmark" code so rarely take the care to validate that the numbers that they are posting actually have any meaning behind them. For example, when you get a "Rate" like "3918166/s", then you should probably just throw away your benchmark results as having no practical meaning. In this particular case, this was a hint that your $s = $s x 10_000_000; line was completely pointless because of other aspects of your code. Fixing that problem (and reducing the string size significantly so it will finish before I need to go to bed), gives: Read more... (1182 Bytes)
which shows how the performance differences are minimal (and the actual difference you'll see in the performance of a real script will be even smaller than that). So the "which will become noticable" assertion was wrong. Update: Here, here! Learning++, (Good attitude)++. - tye | [reply] [d/l] [select] |
by AnomalousMonk (Archbishop) on Jun 12, 2014 at 04:03 UTC | |
I was a bit reluctant to post Re^4: Vowel search because I wasn't sure it was a real contribution to the discussion. Now I'm happy I did because I learned something, even if only not to slap myself in the forehead quite so hard when I realize I've done something stupid. So ++benchmarks! | [reply] |
by Jim (Curate) on Jun 11, 2014 at 23:13 UTC | |
Of course, another approach would be to common-case all lines before matching... Adding this other approach to your benchmark test…
| [reply] [d/l] |