|
Posted by Curtis on 01/03/06 05:47
J.O. Aho <user@example.net> wrote in message
news:41tmf6F1fvlprU1@individual.net...
> Curtis wrote:
> > J.O. Aho <user@example.net> wrote in message
> > news:41t3tcF1gctppU1@individual.net...
> >> Curtis wrote:
> >>
> >>> <?php
> >>> global $user;
> >>> if ($user->uid) {?> <li><a href="logout"
title="">Log
> >>> Out</a></li>
> >>> <?php } else {?> <li><a href="user/login"
title="">Log
> >>> In</a></li>
> >>> <?php }?>
> >>>
> >>> Ten characters in order to type that closing brace?
Wow.
> >> This generates less work for PHP than what
> >>
> >> <?PHP
> >> if ($user->uid) {
> >> echo "<li><a href=\"logout\" title=\"\">Log
> > Out</a></li>";
> >> } else {
> >> echo "<li><a href=\"login\" title=\"\">Log
In</a></li>";
> >> }
> >> ?>
>
> > I'm not sure the tradeoff is anywhere near worth it,
though.
> > Better more work for PHP, I'd think, that be driven
crazy as
> > a code maintainer trying to read the mixed PHP-MTML
soup.
>
> It's first on really slow machines you will be able to
notice it, but today
> most machines are quite fast, I guess quite much is for so
many uses a CPU
> demanding environment on their desktop.
> I do agree that the code is difficult to read, specially
the way it's written
> in the original post. For one or two lines of HTML printed
from PHP is all
> okey, but when you have larger amounts of HTML it's better
to not process that
> at all.
That makes sense.
> > I suspect that on most sites the speed improvement, if
any,
> > would be marginal. I can't speak from much experience,
but
> > in the project I'm working on--a text filter--the text
> > processing done by PHP scanning text twenty-plus times
and
> > substituting this for that would probably dwarf the
output
> > of a little HTML as PHP strings.
>
> On a ~2000MHz x86, the time difference is something like
0.001s for 1000 rows
> of text, so in most servers today you would just spend
extra money when modify
> the code and the gain ain't worth it. But what can be
worth is to make a code
> more readable with comments, which usually seems to be
missing.
An anecdote: along those lines, when I studied text markup
filters before starting my own, I discovered the usual code
bottlenecks. My own code ran 10-1000 times faster,
depending.
Nevertheless, as I added features like macros and include
files--and began to process larger marked-up files, the
timings I was getting on my server started getting longer
and longer. 20,000 characters of marked-up text was taking
..7 to .8 seconds to process. I was fairly certain it was the
WAMP software I was using on a 500MHz machine, for which I
did absolutely ZERO tweaking--it was slow as a pig even to
return a processed web page *locally*.
But I was nevertheless nervous--until I uploaded the package
to my host server and held my breath. What was taking 800
milliseconds (about 20,000 characters of marked-up text) on
my *LOCAL* WAMPed machine took less than 20 milliseconds on
a SHARED host server.
FORTY TIMES FASTER for a doubtless-fairly-user-loaded
machine is rather remarkable.
It just occurred to me to check to server stats. "Processors
4, Model Intel Xeon CPU 2.80GHz Chip MHz 2793.95 MHz, Cache
Size 1024 KB, load average .70"
I'd say that's easily 40 times the machine. They may have
even taken the time to optimize their Apache setup. Ahem.
--
Curtis
Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.
[Back to original message]
|