First off, I don't like that rand there - it makes things much more difficult to replicate. So, after running your test as-is a few times, I went and just changed "rand(1000)" to "1000" and reran it. I got slightly more consistant answers when the strings where consistantly sized.
At no time have I had pack outperform join. Although my CPU seems to be a bit slower than yours ... I never got over 100 runs per second.
Since it seems that the longer the strings, the closer they were, I tried 10,000.As-is: Rate pack join pack 80.0/s -- -15% join 93.7/s 17% -- Always 1000: Rate pack join pack 46.0/s -- -8% join 50.0/s 9% -- x $i rather than x 1000 or x rand(1000): Rate pack join pack 74.0/s -- -14% join 86.0/s 16% --
It doesn't seem that I can get pack outperforming join on this issue. And that's probably despite being utf-8 aware...Rate pack join pack 5.66/s -- -5% join 5.94/s 5% --
Tests above were run on a threaded perl 5.8.7 on Linux
In reply to Re^3: Various ways to concatenating an array of strings
by Tanktalus
in thread Various ways to concatenating an array of strings
by hawtin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |