Presumably, the only thing that the double quotes would slow down is in the parse/compilation phase. After that, it is unlikely that "x" and 'x' would process any differently.

"As fast as possible" means Benchmark, of course:
Benchmark: timing 25 iterations of Double, Single... Double: 2 wallclock secs ( 1.57 usr + 0.01 sys = 1.58 CPU) @ 15 +.82/s (n=25) Single: 1 wallclock secs ( 1.57 usr + 0.01 sys = 1.58 CPU) @ 15 +.82/s (n=25) Rate Double Single Double 15.8/s -- -0% Single 15.8/s 0% --
Which seems to be bang on. If you introduce '$' into the characters that are used to create the random strings, there is a slight difference:
Benchmark: timing 25 iterations of Double, Single... Double: 3 wallclock secs ( 3.13 usr + 0.14 sys = 3.27 CPU) @ 7 +.65/s (n=25) Single: 3 wallclock secs ( 3.18 usr + 0.06 sys = 3.24 CPU) @ 7 +.72/s (n=25) Rate Double Single Double 7.65/s -- -1% Single 7.72/s 1% --
So it would seem that using single or double quotes, apart from functional differences, is merely style. I prefer to use double quotes almost always, except for short single-letter strings, but that's the influence of C where single quotes can only be used for single characters, and double quotes meant 'string'.

And the code for the curious:
#!/usr/bin/perl use Benchmark qw [ cmpthese ]; my (@letter) = ('A'..'Z','a'..'z','0'..'9'); my (@single,@double); sub RandomCrap { return join ('', map { $letter[rand(@letter)] } 0..64); } sub Prep { for (my $i = 0; $i < 5; $i++) { my $func = '@x = ('; for (my $n = 0; $n < 1000; $n++) { $func .= "'".RandomCrap()."',"; } $func .= ')'; push (@single, $func); } @double = map { tr/'/"/; $_ } @single; } sub Evalu { my ($array) = @_; foreach my $func (@$array) { eval $func; } } Prep(); cmpthese (25, { 'Single' => sub { Evalu (\@single); }, 'Double' => sub { Evalu (\@double); }, } );

In reply to Re: String Delimiters by tadman
in thread String Delimiters by pegasus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.