/    Sign up×
Community /Pin to ProfileBookmark

Which echo statement causes the server to work harder

[code=php]echo ‘</p>’ . “n”;[/code]

or

[code=php]echo “</p>n”;[/code]

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@Jeff_MottJul 23.2008 — I would [i]guess[/i] the first one, but really the difference is so minuscule that it isn't even worth thinking about.
Copy linkTweet thisAlerts:
@DoppleauthorJul 23.2008 — Thanks Jeff. Can I just ask what your signature is supposed to do? It looks very intersting.
Copy linkTweet thisAlerts:
@NewsGrailJul 23.2008 — I just tried it, for me the first one was consistently slower by around 0.0005 seconds over 10,000 iterations. You can use this bit of code to quickly benchmark code, run the script a few times to get a consistent time.

[code=php]<?php
$start = explode(' ', microtime());
$start = $start['1'] + $start['0'];

$i = 0;
// Change 10000 to the number of times to run the code. The larger the function the less you will likely want to run it.
while ($i != 10000)
{
// Code you want to benchmark goes here.
echo "</p>n";

++$i;
}

$finish = explode(' ', microtime());
$finish = $finish['1'] + $finish['0'];

echo '<p style="margin:auto;text-align:center">'.round(($finish-$start), 6).' seconds</p>';
?>[/code]
Copy linkTweet thisAlerts:
@NogDogJul 23.2008 — I just tried it, for me the first one was consistently slower by around 0.0005 seconds over 10,000 iterations. You can use this bit of code to quickly benchmark code, run the script a few times to get a consistent time....[/QUOTE]
Is that 0.0005 seconds per iteration, or per the full 10,000 iterations. If the latter, it's not even worth a second of [i]your[/i] time to worry about. If the former (.0005sec/instance) it's still really not worth worrying about unless you're programming some large, intense, high-demand application where every microsecond matters.
Copy linkTweet thisAlerts:
@NewsGrailJul 23.2008 — Over the full 10,000.
Copy linkTweet thisAlerts:
@DoppleauthorJul 23.2008 — I thought the difference would be negligable but I just like to be tidy!

Thanks for the bit of benchmarking code though. It will come in handy!
Copy linkTweet thisAlerts:
@MrCoderJul 23.2008 — Is that 0.0005 seconds per iteration, or per the full 10,000 iterations. If the latter, it's not even worth a second of [i]your[/i] time to worry about. If the former (.0005sec/instance) it's still really not worth worrying about unless [B]you're programming some large, intense, high-demand application where every microsecond matters.[/B][/QUOTE]

In PHP??!?
Copy linkTweet thisAlerts:
@NogDogJul 23.2008 — In PHP??!?[/QUOTE]
Exactly. When microseconds become important, it's probably time to to brush up on your Assembler skills. ?
Copy linkTweet thisAlerts:
@MrCoderJul 23.2008 — Exactly. When microseconds become important, it's probably time to to brush up on your Assembler skills. ?[/QUOTE]

Or this..
×

Success!

Help @Dopple spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...