That was an interesting thread. Base on those numbers, double and single quote really does not have much speed difference and the difference is not consistent. bass_warrior's testing was meaningless, he made up cases to drive a pre-determined conclusion.
I slightly modified the first set of benchmark provided by Anonymous Monk, and when the string is a little bit longer, the chance of winning between double and single quote becomes really close to 50-50:
use warnings; use Benchmark("cmpthese"); cmpthese(-1, { "double", q !eval q {$a = "this is a string" x 10}!, 'single', q !eval q {$b = 'this is a string' x 10}!, });
Conclusion: the difference between single and double quote are more functional than performance.
Update: when I tried x 100, double seems to win more. In a way, it shows that length of the string matters here. The overall conclusion stays, the speed difference does not mean much.
In reply to Re^2: Differences between " " and ' '?
by pg
in thread Differences between " " and ' '?
by Ace128
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |