Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Differences between " " and ' '?

by polypompholyx (Chaplain)
on Jul 31, 2005 at 09:36 UTC ( #479697=note: print w/replies, xml ) Need Help??

in reply to Re^2: Differences between " " and ' '?
in thread Differences between " " and ' '?

D:\perl> perl -MBenchmark -e "timethese( 1000000, { doubles => sub { my $interpolated = \"pomperipossa\" }, singles => sub {my $uninterpolated = 'pomperipossa' } } )"

Gives these results:

Benchmark: timing 1000000 iterations of doubles, singles...

doubles:  0 wallclock secs ( 0.46 usr +  0.00 sys =  0.46 CPU) @ 2169197.40/s (n=1000000)

singles:  0 wallclock secs ( 0.45 usr +  0.00 sys =  0.45 CPU) @ 2217294.90/s (n=1000000)

So in this (highly unrealistic) case, singles seem infinitesimally faster. I use singles for things I think will be constant, and doubles only when I actually want interpolation. But this is nothing to do with alleged speed benefits, and everything to do with making my intentions clear.

Replies are listed 'Best First'.
Re^4: Differences between " " and ' '?
by diotalevi (Canon) on Jul 31, 2005 at 23:10 UTC
    They are both 100% identical, internally. Any speed difference is the result of system noise and not because anything was measured. If you wished to measure the difference in compilation speed, use string-eval. That's the only time anything different will happen. I'm not going to run this code because any actual difference is going to be so infinitessimal that it will be undectable above system noise.

    use Benchmark; $bar = ''; timethese( 0, { doubles => sub { eval "$bar" }, singles => sub { eval '$bar' } } );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://479697]
[shmem]: No, not coincidence - prejudice and bias
[shmem]: your scanner is pre-loaded ;-)
[shmem]: anyways, do as is your wont. I won't fight western hypocresy anymore - for today. Let's call that a day, and done.
[erix]: yeah, scanning pre-loaded. I wouldn't have it any other way. As I say, my attention is a rare commodity, jealously guarded.
[erix]: ok, ok. happy pipe-dreams :P

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-03-19 21:12 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.