Curious if anyone knows (or can easily test) the time it takes to reference and then dereference an array.
my @foo = (0..1500000); # (~1.5M nodes).
join('',@{\@foo}); # any noticeable time difference vs join('',@foo) ?
There’s obviously no legitimate reason for this, but I’ve come across unreasonable code 🙂
Benchmarks of similar tests I’ve performed gave something on the order 10 nanoseconds per deref. There’s only deref in the code you posted, so we’re talking about a 0.000,000,010s difference.
Bah, the difference is so tiny, that I can’t even reliably tell which one is faster!
array is faster 50% of the time, array ref is faster 50% of the time.
Here’s a better test than the one you posted. The only you posted spent less than 1% of the time doing the thing you wanted to test.
But again, the different is so small, that it’s not measurable. Sometimes array ref appears faster, sometimes the array appears faster.
Again, array is faster 50% of the time, array ref is faster 50% of the time.