Re: [PHP] long echo statement performance question

2009-02-06 Thread Richard Heyes
 ...

Wouldn't have thought so. But for readability, you may find this a
little easier instead:

?
{$var1} Blah {$var2}
...
?php

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.org (Updated January 31st)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Bruno Fajardo
In my opinion, you would achieve better results using a template
engine, like Smarty (http://www.smarty.net/). In addition, your code
would be entirely separated from presentation in a elegant way.

2009/2/6 Frank Stanovcak blindspot...@comcast.net:
 I'm in the process of seperating logic from display in a section of code,
 and wanted to make sure I wasn't treading on a performance landmine here, so
 I ask you wizened masters of the dark arts this...

 is there a serious performance hit, or reason not to use long, ie more than
 30 - 40 lines, comma conjoined echo statments...

 echo 'blah', $var, 'blah', $var2,...ad nauseum

 ... to output mixed html and php var values?  If so could you refer me to a
 work around, or better way?

 Frank



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
Bruno Fajardo - Desenvolvimento
bruno.faja...@dinamize.com - www.dinamize.com
Dinamize RS - Porto Alegre-RS - CEP 90420-111
Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
Dinamize SC - Joinville - Fone 47 3025.1182
Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
Dinamize SP - São Paulo - Fone 11 6824.6250
Dinamize PR - Curitiba - Fone 41 3306.4388
Dinamize RS - Caxias do Sul - Fone 54 3533.4333
Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Richard Heyes
 Wouldn't have thought so. But for readability, you may find this a
 little easier instead:

Slight correction:

?
?=$var1? blah ?=var2?
?php

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.org (Updated January 31st)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Frank Stanovcak

Richard Heyes rich...@php.net wrote in message 
news:af8726440902060918v6d2f1ee1ia3f839189874...@mail.gmail.com...
 Wouldn't have thought so. But for readability, you may find this a
 little easier instead:

 Slight correction:

 ?
?=$var1? blah ?=var2?
 ?php

 -- 
 Richard Heyes

 HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated January 31st)

Actually that's what I'm in the middle of undoing.  The first revision was 
jumping in and out of PHP mode upwards of 60 times per page on the shorter 
pages.  I've read a couple places that that can put a huge performace hit on 
things, so I was just trying to simplify the code a bit.  Plus I don't have 
the fast tags, ?=, enabled *blush* 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Frank Stanovcak

Bruno Fajardo bsfaja...@gmail.com wrote in message 
news:eeb6980b0902060915k2b34ec31nc6ad166e2c544...@mail.gmail.com...
In my opinion, you would achieve better results using a template
engine, like Smarty (http://www.smarty.net/). In addition, your code
would be entirely separated from presentation in a elegant way.

2009/2/6 Frank Stanovcak blindspot...@comcast.net:
 I'm in the process of seperating logic from display in a section of code,
 and wanted to make sure I wasn't treading on a performance landmine here, 
 so
 I ask you wizened masters of the dark arts this...

 is there a serious performance hit, or reason not to use long, ie more 
 than
 30 - 40 lines, comma conjoined echo statments...

 echo 'blah', $var, 'blah', $var2,...ad nauseum

 ... to output mixed html and php var values?  If so could you refer me to 
 a
 work around, or better way?

 Frank



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
Bruno Fajardo - Desenvolvimento
bruno.faja...@dinamize.com - www.dinamize.com
Dinamize RS - Porto Alegre-RS - CEP 90420-111
Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

I'm going to take a serious look at that for ver 2.0, but unfortunately live 
beta 1 rollout is monday, and I'm just cleaning house right now.  Thanks for 
the advice though!

Frank 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Stuart
2009/2/6 Frank Stanovcak blindspot...@comcast.net:

 Richard Heyes rich...@php.net wrote in message
 news:af8726440902060918v6d2f1ee1ia3f839189874...@mail.gmail.com...
 Wouldn't have thought so. But for readability, you may find this a
 little easier instead:

 Slight correction:

 ?
?=$var1? blah ?=var2?
 ?php

 --
 Richard Heyes

 HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated January 31st)

 Actually that's what I'm in the middle of undoing.  The first revision was
 jumping in and out of PHP mode upwards of 60 times per page on the shorter
 pages.  I've read a couple places that that can put a huge performace hit on
 things, so I was just trying to simplify the code a bit.  Plus I don't have
 the fast tags, ?=, enabled *blush*

They're called short tags, not fast tags. There is nothing faster
about them beyond the typing effort required.

This question, or rather variations of it, appear on this list at
pretty regular intervals. A little while ago I wrote a script to test
the speed of various output methods.

http://stut.net/projects/phpspeed/?iterations=1

As you can see, the difference is so minimal that unless you're doing
it hundreds of thousands of times per script it makes little
difference how you do it.

In short it's usually not worth optimising at this level since greater
gains are certainly to be had by looking at your interaction with
databases or other external resources.

-Stuart

-- 
http://stut.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Eric Butera
On Fri, Feb 6, 2009 at 12:15 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 In my opinion, you would achieve better results using a template
 engine, like Smarty (http://www.smarty.net/). In addition, your code
 would be entirely separated from presentation in a elegant way.

 2009/2/6 Frank Stanovcak blindspot...@comcast.net:
 I'm in the process of seperating logic from display in a section of code,
 and wanted to make sure I wasn't treading on a performance landmine here, so
 I ask you wizened masters of the dark arts this...

 is there a serious performance hit, or reason not to use long, ie more than
 30 - 40 lines, comma conjoined echo statments...

 echo 'blah', $var, 'blah', $var2,...ad nauseum

 ... to output mixed html and php var values?  If so could you refer me to a
 work around, or better way?

 Frank



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





 --
 Bruno Fajardo - Desenvolvimento
 bruno.faja...@dinamize.com - www.dinamize.com
 Dinamize RS - Porto Alegre-RS - CEP 90420-111
 Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

 Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
 Dinamize SC - Joinville - Fone 47 3025.1182
 Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
 Dinamize SP - São Paulo - Fone 11 6824.6250
 Dinamize PR - Curitiba - Fone 41 3306.4388
 Dinamize RS - Caxias do Sul - Fone 54 3533.4333
 Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



In a thread about performance you suggest Smarty?  Really?  :D

-- 
http://www.voom.me | EFnet: #voom

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Bruno Fajardo
Well, Smarty's caching layer is very fast. Maybe not as fast as an
echo statement, but apparentely Frank was also interested in separate
logic from presentation, and a series of echo's is not the best
solution in my opinion. :-)
But the best solution depends of the context of the application, i agree.

2009/2/6 Eric Butera eric.but...@gmail.com:
 On Fri, Feb 6, 2009 at 12:15 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 In my opinion, you would achieve better results using a template
 engine, like Smarty (http://www.smarty.net/). In addition, your code
 would be entirely separated from presentation in a elegant way.

 2009/2/6 Frank Stanovcak blindspot...@comcast.net:
 I'm in the process of seperating logic from display in a section of code,
 and wanted to make sure I wasn't treading on a performance landmine here, so
 I ask you wizened masters of the dark arts this...

 is there a serious performance hit, or reason not to use long, ie more than
 30 - 40 lines, comma conjoined echo statments...

 echo 'blah', $var, 'blah', $var2,...ad nauseum

 ... to output mixed html and php var values?  If so could you refer me to a
 work around, or better way?

 Frank



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 In a thread about performance you suggest Smarty?  Really?  :D

 --
 http://www.voom.me | EFnet: #voom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Eric Butera
On Fri, Feb 6, 2009 at 1:43 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 Well, Smarty's caching layer is very fast. Maybe not as fast as an
 echo statement, but apparentely Frank was also interested in separate
 logic from presentation, and a series of echo's is not the best
 solution in my opinion. :-)
 But the best solution depends of the context of the application, i agree.

Right on.  I was just playing anyways.  I'm a strong supporter of
things like Savant  Zend_View.  Use PHP, but for read only type of
things with no logic.

-- 
http://www.voom.me | EFnet: #voom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Bruno Fajardo
I am so stick to Smarty that I never tried other solutions, like
Savant. Thanks for the tip, I'll try it right away.

Cheers.

2009/2/6 Eric Butera eric.but...@gmail.com:
 On Fri, Feb 6, 2009 at 1:43 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 Well, Smarty's caching layer is very fast. Maybe not as fast as an
 echo statement, but apparentely Frank was also interested in separate
 logic from presentation, and a series of echo's is not the best
 solution in my opinion. :-)
 But the best solution depends of the context of the application, i agree.

 Right on.  I was just playing anyways.  I'm a strong supporter of
 things like Savant  Zend_View.  Use PHP, but for read only type of
 things with no logic.

 --
 http://www.voom.me | EFnet: #voom




-- 
Bruno Fajardo - Desenvolvimento
bruno.faja...@dinamize.com - www.dinamize.com
Dinamize RS - Porto Alegre-RS - CEP 90420-111
Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
Dinamize SC - Joinville - Fone 47 3025.1182
Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
Dinamize SP - São Paulo - Fone 11 6824.6250
Dinamize PR - Curitiba - Fone 41 3306.4388
Dinamize RS - Caxias do Sul - Fone 54 3533.4333
Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Eric Butera
On Fri, Feb 6, 2009 at 2:10 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 I am so stick to Smarty that I never tried other solutions, like
 Savant. Thanks for the tip, I'll try it right away.

 Cheers.

 2009/2/6 Eric Butera eric.but...@gmail.com:
 On Fri, Feb 6, 2009 at 1:43 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 Well, Smarty's caching layer is very fast. Maybe not as fast as an
 echo statement, but apparentely Frank was also interested in separate
 logic from presentation, and a series of echo's is not the best
 solution in my opinion. :-)
 But the best solution depends of the context of the application, i agree.

 Right on.  I was just playing anyways.  I'm a strong supporter of
 things like Savant  Zend_View.  Use PHP, but for read only type of
 things with no logic.

 --
 http://www.voom.me | EFnet: #voom




 --
 Bruno Fajardo - Desenvolvimento
 bruno.faja...@dinamize.com - www.dinamize.com
 Dinamize RS - Porto Alegre-RS - CEP 90420-111
 Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

 Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
 Dinamize SC - Joinville - Fone 47 3025.1182
 Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
 Dinamize SP - São Paulo - Fone 11 6824.6250
 Dinamize PR - Curitiba - Fone 41 3306.4388
 Dinamize RS - Caxias do Sul - Fone 54 3533.4333
 Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311


Keep in mind it won't keep people from running whatever code they
want.  It's more of a discipline you must enforce upon yourself and
development team.  It works out well for me though, but all
requirements are different.

-- 
http://www.voom.me | EFnet: #voom

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Paul M Foster
On Fri, Feb 06, 2009 at 01:09:13PM -0500, Eric Butera wrote:

 On Fri, Feb 6, 2009 at 12:15 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
  In my opinion, you would achieve better results using a template
  engine, like Smarty (http://www.smarty.net/). In addition, your code
  would be entirely separated from presentation in a elegant way.
 

snip

 
 In a thread about performance you suggest Smarty?  Really?  :D
 

You know, I was gonna say something about that, but I figure I've
complained enough on list. I agree, though.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Frank Stanovcak

Stuart stut...@gmail.com wrote in message 
news:a5f019de0902060932k1ccf2948ua42f3cfa33694...@mail.gmail.com...
 2009/2/6 Frank Stanovcak blindspot...@comcast.net:

 Richard Heyes rich...@php.net wrote in message
 news:af8726440902060918v6d2f1ee1ia3f839189874...@mail.gmail.com...
 Wouldn't have thought so. But for readability, you may find this a
 little easier instead:

 Slight correction:

 ?
?=$var1? blah ?=var2?
 ?php

 --
 Richard Heyes

 HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated January 31st)

 Actually that's what I'm in the middle of undoing.  The first revision 
 was
 jumping in and out of PHP mode upwards of 60 times per page on the 
 shorter
 pages.  I've read a couple places that that can put a huge performace hit 
 on
 things, so I was just trying to simplify the code a bit.  Plus I don't 
 have
 the fast tags, ?=, enabled *blush*

 They're called short tags, not fast tags. There is nothing faster
 about them beyond the typing effort required.

 This question, or rather variations of it, appear on this list at
 pretty regular intervals. A little while ago I wrote a script to test
 the speed of various output methods.

http://stut.net/projects/phpspeed/?iterations=1

 As you can see, the difference is so minimal that unless you're doing
 it hundreds of thousands of times per script it makes little
 difference how you do it.

 In short it's usually not worth optimising at this level since greater
 gains are certainly to be had by looking at your interaction with
 databases or other external resources.

 -Stuart

 -- 
 http://stut.net/

Thanks Stuart!
So for clarity's sake jumping into and out of PHP parsing mode to echo a var 
isn't going to do as great a performance hit as these naysayers would have 
me believe.  Good.  I like the color coding of my html in my editor that is 
lost when I have to quote it to get it to echo/print properly!

Frank 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Daevid Vincent
On Fri, 2009-02-06 at 17:32 +, Stuart wrote:


 They're called short tags, not fast tags. There is nothing faster
 about them beyond the typing effort required.

Mostly true.

However, the only thing that ?= ? does is an echo/print, so aside
from saving you ?php echo $foo; ? all the time, you can't do ?= if
($foo) print 'blah'; ? 

Personally, I love them.

 http://stut.net/projects/phpspeed/?iterations=1

God bless you son for making this f'n amazing page! 

Ironically it doesn't have ?= $x ? in it though. HAHA! can you add
that to your test suite too?

D.Vin
http://daevid.com



Re: [PHP] long echo statement performance question

2009-02-06 Thread Sancar Saran
On Friday 06 February 2009 19:12:08 Frank Stanovcak wrote:
 I'm in the process of seperating logic from display in a section of code,
 and wanted to make sure I wasn't treading on a performance landmine here,
 so I ask you wizened masters of the dark arts this...

 is there a serious performance hit, or reason not to use long, ie more than
 30 - 40 lines, comma conjoined echo statments...

 echo 'blah', $var, 'blah', $var2,...ad nauseum

 ... to output mixed html and php var values?  If so could you refer me to a
 work around, or better way?

 Frank

Seperate logic.

Not the template.

?=$variable? was good for templating. With opcode cache all your template 
was cached.

And of course you should not use write functions in templates.

and if you really want to do this with

echo  yada yada I suggest this one.

$output = '';


do someting remove echo  and put $output.

and end of the script

do echo $output.

This was the best way. Of course you can use output buffering. 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] long echo statement performance question

2009-02-06 Thread Stephen

I have been reading this thread with interest ... and amusement.

FWII for my web sites I have

1) Most PHP code in files outside of the document root
2) Site specific variables (constants, really) in an include.php file
3) All HTML is also in this include file and is the content a variable.
4) Nested in the HTML code are variables for the content, like the menu 
and body text

5) All presentation is done using CSS
6) Each page just has PHP code (mostly function calls) where the content 
variables are built

7) Finally the content variable is echoed.

Stephen

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php