Re: getting one line from file
| From: | Heikki Korpela | Date: | Thu, 31 Aug 2000 14:19:55 +0000 |
| Subject: | Re: getting one line from file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14617@lists.php.net to get a copy of this message | ||
Michael Packer wrote:
> yes yes yes...i think i have 20 mail messages from people saying to do
> this...i would if i could, the problem is this data is changing all the time
> and being copied from another machine to the webserver. therefore i would
> have to either reload the database each time the data changed or determine
> what has changed each time it is copied and then modify the sql
> databases....which i believe either way would be a bigger load on the
> system.
> pac
IMHO, there is no need to place data in a database when a filesystem would do.
If you're just grepping one line, it is very unreasonable to keep the
whole freaking 7M:s in a database. In MySQL, databases are files themselves,
so I hardly see the point.
The problem is I don't understand how can you possibly have such a difference
between the Perl and PHP implementation. Here are some benchmarks on my
desktop server, scanning /usr/dict/words (400k) for its last word.
-- Terminal dump start --
[heikki@heikki heikki]$ cat > bin/phplinefile
#!/usr/local/bin/php
<?php
header("Content-Type: text/plain");
$line =
grep 'Zurich' /usr/dict/words;
print $line;
?>
[heikki@heikki heikki]$ cat > bin/pllinefile
#!/usr/bin/perl
print "Content-Type: text/plain\r\n\r\n";
$line = grep Zurich /usr/dict/words;
print $line;
[heikki@heikki heikki]$ time -p pllinefile
Content-Type: text/plain
Zurich
real 0.02
user 0.01
sys 0.01
[heikki@heikki heikki]$ time -p phplinefile
X-Powered-By: PHP/4.0.2
Content-Type: text/plain
Zurich
real 0.06
user 0.04
sys 0.02
[heikki@heikki heikki]$ ln -s ~/bin/pllinefile ~/public_html/linefile.cgi
[heikki@heikki heikki]$ ln -s ~/bin/phplinefile ~/public_html/linefile.php
[heikki@heikki heikki]$ time -p lynx -dump http://localhost/linefile.cgi
Zurich
real 0.07
user 0.03
sys 0.02
[heikki@heikki heikki]$ time -p lynx -dump http://localhost/linefile.php
#!/usr/local/bin/php Zurich
real 0.07
user 0.04
sys 0.01
-- Terminal dump end ---
Perhaps you could check your PHP options.
--
| Heikki Korpela | heikki.korpela@wapit.com | tel. +358 50 3838 609 |
| Software Developer, Wapit Finland | http://www.wapit.com |
--
"Even though it does not work, how does it feel?"