Re: [php-49] PHP speed test site

From: Tim P.
Sent on: Tuesday, November 20, 2012 10:23 PM
I always thought double quotes (string interpolation) was slower than concatenation?


Sent from my iPhone

On Nov 20, 2012, at 10:15 PM, Kris Craig <[address removed]> wrote:

You mean would it be faster to do "this number: $b" or 'this number: ' . $b?

I'm not sure what the latest data is on substitution and the speedtest site didn't really compare that.  My hypothesis would be that the double quotes would perform slightly faster given the baselines, but I don't have the hardware I'd need to do a scientifically accurate performance test.

You could test it yourself and then let us know what you came up with.  Just take a microtime() measurement before and after each instance you're testing and compare the differences.  Also be sure to note the exact PHP version and relevant environment info (OS, run via webserver or CLI, etc).  It won't be scientific, obviously, but it's a place to start at least.

--Kris


On Tue, Nov 20, 2012 at 9:30 PM, Eric Harris <[address removed]> wrote:
When looking at double vs single quotes, does that apply when using variables with in the double quotes? ie: $b = 10; $a = "this number: $b"; My understand was that it was not the quotes itself, but the substitution that happens within the double quotes with variables. Is that incorrect?

-- Eric

On Tue, Nov 20, 2012 at 8:32 PM, Kris Craig <[address removed]> wrote:
Yep that's a good resource.  Their methodology is hardly scientific (i.e. server load/traffic is an ever-changing and unknown variable that can wildly throw off the results) so you should take what's there for a grain of salt.  That said, it does give you a good idea about how different things perform.

One thing I always like to point out there is the difference between double quotes and single quotes.  Contrary to conventional thought, double quotes actually perform better than single quotes in all cases, except when special characters are being included verbatim (i.e. escaped in double quotes).  Most people still cling to the outdated notion that $a = ''; is faster than $a = ""; when in fact the exact opposite is true.

--Kris


On Tue, Nov 20, 2012 at 5:41 PM, Ken Ploeger <[address removed]> wrote:
http://www.phpbench.com/

-----Original Message-----
From: [address removed] [mailto:[address removed]] On Behalf Of Mark Steudel
Sent: Tuesday, November 20,[masked]:25 PM
To: [address removed]
Subject: [php-49] PHP speed test site

There was a php site that had a list of benchmarks listed out, like is a for
loop faster than a foreach loop, anyone know that off the top of their head?

--
-----------------------------------------
Mark Steudel
P: [masked]
F: [masked]
[address removed]

. : Work : .
http://www.mindfulinteractive.com

. : Play : .
http://www.steudel.org/blog

. : LinkedIn : .
http://www.linkedin.com/in/steudel



--
Please Note: If you hit "REPLY", your message will be sent to everyone on
this mailing list ([address removed]) http://www.meetup.com/php-49/ This
message was sent by Mark Steudel ([address removed]) from The Seattle PHP
Meetup Group.
To learn more about Mark Steudel, visit his/her member profile:
http://www.meetup.com/php-49/members/2764664/
Set my mailing list to email me

As they are sent
http://www.meetup.com/php-49/list_prefs/?pref=1

In one daily email
http://www.meetup.com/php-49/list_prefs/?pref=2

Don't send me mailing list messages
http://www.meetup.com/php-49/list_prefs/?pref=0
Meetup, PO Box 4668 #37895 New York, New York[masked] |
[address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
http://www.meetup.com/php-49/
This message was sent by Ken Ploeger ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Ken Ploeger, visit his/her member profile: http://www.meetup.com/php-49/members/18250081/
Set my mailing list to email me

As they are sent
http://www.meetup.com/php-49/list_prefs/?pref=1

In one daily email
http://www.meetup.com/php-49/list_prefs/?pref=2

Don't send me mailing list messages
http://www.meetup.com/php-49/list_prefs/?pref=0
Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]






--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Kris Craig ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Kris Craig, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Eric Harris ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Eric Harris, visit his/her member profile





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Kris Craig ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Kris Craig, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy