NYCPHP Meetup

NYPHP.org

[nycphp-talk] testing a theory

Nicholas Tang ntang at communityconnect.com
Tue Feb 6 18:50:42 EST 2007


I'd agree, but I'd also say:

1.) Test, test, test... It'll take 5 minutes to run a quick benchmark
and find out.

2.) My guess is that neither is going to have a significant performance
impact, and that it's probably not worth worrying about in the big
picture.  Look for low-hanging fruit first, if you're optimizing your
app.  Now, on the other hand, if the real-world example is concatenating
a million different lines of text before printing, that could add up...

Nicholas 

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Ben Sgro (ProjectSkyline)
Sent: Tuesday, February 06, 2007 6:48 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] testing a theory

Well,

My guess (no facts here) would be the first is slower.

First the "'s need to be checked for $variables, it would be quicker to
put '.
And then an operation of copying needs to be done. Allocation as well on
the c side for the new, larger variable.

Then the display.

The second snippet displays the lines without the additional operation
of allocation/concatenation.

Who knows though..I'd like a more fact based explanation.

- Ben
----- Original Message -----
From: "Adrian Noland" <anoland at indigente.net>
To: <talk at lists.nyphp.org>
Sent: Tuesday, February 06, 2007 6:39 PM
Subject: [nycphp-talk] testing a theory


> Hi, I have a quick (and probably silly) question. Is there performance
> difference between the following two snippets. Does it make a
> difference if there are hundreds+ of lines?
>
> <?php
> $content = "this is the start of a bunch of lines";
> $content .= "another line";
> $content .= "yet another";
> echo $content;
> ?>
>
> vs.
>
> <?php
> echo "this is the start of a bunch of lines";
> echo "another line";
> echo "yet another";
> ?>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
> 

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

!DSPAM:3343,45c913c833191619412130!





More information about the talk mailing list