[wp-trac] [WordPress Trac] #31950: Reduce PHP memory usage / No unnecessary concatenation

WordPress Trac noreply at wordpress.org
Thu Jul 2 11:37:08 UTC 2015


#31950: Reduce PHP memory usage / No unnecessary concatenation
-----------------------------------+------------------------------
 Reporter:  jrf                    |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  General                |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:  performance
-----------------------------------+------------------------------

Comment (by GaryJ):

 Replying to [comment:3 johnbillion]:

 > > For more information, see:
 > > https://github.com/dseguy/clearPHP/blob/master/rules/no-unnecessary-
 string-concatenation.md
 > > https://github.com/dseguy/clearPHP/blob/master/rules/no-repeated-
 print.md
 >
 > Those two "rules" conflict with each other. Which is it to be?

 I don't see them as conflicting. The first says not do:

 {{{
 echo $a . $b . $c;
 }}}

 and the second says not to do:

 {{{
 echo $a;
 echo $b;
 echo $c;
 }}}

 The patch here advocates:

 {{{
 echo $a, $b, $c;
 }}}

 ----

 A very quick benchmark, based on code from http://www.electrictoolbox.com
 /php-echo-commas-vs-concatenation/
 suggests that commas (http://3v4l.org/48KHh/perf#tabs) are generally
 better performing than concat (http://3v4l.org/alrdD/perf#tabs). The
 following tests / links also agree.

 * https://www.fusionswift.com/2010/05/php-concatenation-benchmark-comma-
 vs-period/
 * https://phpgoodness.wordpress.com/2010/07/23/some-php-performance-myths/
 * http://www.spudsdesign.com/index.php?t=echo1

 These are obviously no replacement for a real test of WP, but should be
 enough to consider doing that benchmark.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31950#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list