php-windows Digest 25 Apr 2007 14:10:16 -0000 Issue 3207
Topics (messages 27746 through 27763):
Re: $date1 larger then current date?
27746 by: Mikael Grön
slow performance
27747 by: Henning Eiben
Re: [PHP] slow performance
27748 by: Stut
27749 by: Henning Eiben
27750 by: Zoltán Németh
27751 by: Henning Eiben
27755 by: Zoltán Németh
27756 by: Henning Eiben
27757 by: Stanislav Malyshev
27758 by: Henning Eiben
27759 by: Stanislav Malyshev
27760 by: Henning Eiben
27761 by: Stanislav Malyshev
27762 by: Henning Eiben
27763 by: Stanislav Malyshev
Regular expression
27752 by: Mikael Grön
27753 by: Kevin Smith
27754 by: Kevin Smith
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Try:
if ($date1 > $date2) {
echo "First date is a later one than Second date";
} else {
echo "Second date is the latest.";
}
It's just as easy as you thought it'd be.
Mike
Gustav Wiberg skrev:
Hi guys!
I'm searching for what I thought would be an easy issue comparing dates. I just want to know if a date in variable
$date1 is larger then current date.
I use the format YYYY-MM-DD in $date1
and I know how to retrieve the current date and set it in $dat2
But how do I know if $date1> $date2 ?
I have looked around, but I havent found any easy solution. It seems to be a big deal? Is that the case?
Best regards
/Gustav Wiberg
--- End Message ---
--- Begin Message ---
Hi,
I wrote a small sample-application once using PHP (with propel and
smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are
being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the
performance of the PHP version is much slower than the Java version.
I already installed an php-accelerator (eAccelator) which increased the
overall performance, but still the performance is quite poor.
Are there any "tweaks" to tune PHP performance?
--
... Does killing time harm eternity?
--- End Message ---
--- Begin Message ---
Henning Eiben wrote:
I wrote a small sample-application once using PHP (with propel and
smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are
being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the
performance of the PHP version is much slower than the Java version.
I already installed an php-accelerator (eAccelator) which increased the
overall performance, but still the performance is quite poor.
Are there any "tweaks" to tune PHP performance?
Don't use Windows.
If you *must* use windows, use FastCGI.
-Stut
--- End Message ---
--- Begin Message ---
Stut schrieb:
>> I wrote a small sample-application once using PHP (with propel and
>> smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are
>> being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the
>> performance of the PHP version is much slower than the Java version.
>>
>> I already installed an php-accelerator (eAccelator) which increased the
>> overall performance, but still the performance is quite poor.
>>
>> Are there any "tweaks" to tune PHP performance?
>
> Don't use Windows.
Well, I don't really have any option. Also I have to use IIS as a webserver.
> If you *must* use windows, use FastCGI.
OK, so FastCGI is much better than ISAPI? Looking quickly at the
installation-docs, FastCGI is not explicitly mentioned. So basically I
would just use php5-cgi.exe instead of php5-isapi.dll?
--
... There are 10 kinds of people. Those who know binary code, and those
who don't.
--- End Message ---
--- Begin Message ---
2007. 04. 25, szerda keltezéssel 11.33-kor Henning Eiben ezt írta:
> Hi,
>
> I wrote a small sample-application once using PHP (with propel and
> smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are
> being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the
> performance of the PHP version is much slower than the Java version.
I think this is because Java is compiled once, PHP is compiled at every
request...
>
> I already installed an php-accelerator (eAccelator) which increased the
> overall performance, but still the performance is quite poor.
I would not say php performace is poor, I think it is quite fast (at
least on my linux boxes, I know nothing about php on windows...)
>
> Are there any "tweaks" to tune PHP performance?
I do not know about tweaks but there might be ;)
greets
Zoltán Németh
>
>
> --
> ... Does killing time harm eternity?
>
--- End Message ---
--- Begin Message ---
Zoltán Németh schrieb:
>> I wrote a small sample-application once using PHP (with propel and
>> smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are
>> being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the
>> performance of the PHP version is much slower than the Java version.
>
> I think this is because Java is compiled once, PHP is compiled at every
> request...
Well, but using something like eAccelerator should compensate this,
shouldn't it? As far as I understand, scripts are being compiled and
then store in memory to access them faster.
>> I already installed an php-accelerator (eAccelator) which increased the
>> overall performance, but still the performance is quite poor.
>
> I would not say php performace is poor, I think it is quite fast (at
> least on my linux boxes, I know nothing about php on windows...)
Well ... I did some stress-testing. I create 20 concurrent requests to
my application: random pages, randomizing the post parameter, which
causes to load different data from the database (MySQL 5.0.37, running
on a separate server). My webserver is the same for java and php.
Running my test for about 5 minutes, I get about 31.000 request for the
java application, but only about 3.000 for the php.
--
... Does killing time harm eternity?
--- End Message ---
--- Begin Message ---
2007. 04. 25, szerda keltezéssel 11.53-kor Henning Eiben ezt írta:
> Zoltán Németh schrieb:
>
> >> I wrote a small sample-application once using PHP (with propel and
> >> smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are
> >> being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the
> >> performance of the PHP version is much slower than the Java version.
> >
> > I think this is because Java is compiled once, PHP is compiled at every
> > request...
>
> Well, but using something like eAccelerator should compensate this,
> shouldn't it? As far as I understand, scripts are being compiled and
> then store in memory to access them faster.
not exactly. it pre-compiles them to opcodes and stores the opcode
blocks. the interpreter normally first pre-compiles the code to opcodes
then runs the opcode. this pre-compilation can be cached with
accelerators, that's how they increase performance.
>
> >> I already installed an php-accelerator (eAccelator) which increased the
> >> overall performance, but still the performance is quite poor.
> >
> > I would not say php performace is poor, I think it is quite fast (at
> > least on my linux boxes, I know nothing about php on windows...)
>
> Well ... I did some stress-testing. I create 20 concurrent requests to
> my application: random pages, randomizing the post parameter, which
> causes to load different data from the database (MySQL 5.0.37, running
> on a separate server). My webserver is the same for java and php.
>
> Running my test for about 5 minutes, I get about 31.000 request for the
> java application, but only about 3.000 for the php.
well, that's strange. I think there should not be that much difference.
maybe your php code is written poorly?
or maybe your apache serves php in a way which limits the number of
threads or some other resource?
or else I don't know. (but I'm not a performance guru, wait for answers
from some other list members who know much more about this topic than
me ;) )
greets
Zoltán Németh
>
>
>
> --
> ... Does killing time harm eternity?
>
--- End Message ---
--- Begin Message ---
Zoltán Németh wrote:
>>>> I already installed an php-accelerator (eAccelator) which increased the
>>>> overall performance, but still the performance is quite poor.
>>> I would not say php performace is poor, I think it is quite fast (at
>>> least on my linux boxes, I know nothing about php on windows...)
>> Well ... I did some stress-testing. I create 20 concurrent requests to
>> my application: random pages, randomizing the post parameter, which
>> causes to load different data from the database (MySQL 5.0.37, running
>> on a separate server). My webserver is the same for java and php.
>>
>> Running my test for about 5 minutes, I get about 31.000 request for the
>> java application, but only about 3.000 for the php.
>
> well, that's strange. I think there should not be that much difference.
> maybe your php code is written poorly?
could be ... but my java code might be poorly as well :). Using propel
an smarty might not be the way to go, to get the fastest performance,
but from the architectural point of view this is somehow similar to
using EJB3 and JSP.
> or maybe your apache serves php in a way which limits the number of
> threads or some other resource?
well, I'm using IIS not apache :), but I also tried Apache 2.2.4
(Windows), and the performance increase was just about 10%
--
... Gentlemen: Start your debuggers...
--- End Message ---
--- Begin Message ---
OK, so FastCGI is much better than ISAPI? Looking quickly at the
Not exactly so - the thing here is that non-threadsafe PHP is faster
than threadsafe PHP - since no inter-thread locking is necessary. And
since ISAPI PHP must be TS and FastCGI PHP can be non-TS - the FastCGI
PHP ends up being faster. Note that is you just use thread-safe FastCGI
you probably won't get any benefits. IIRC standard PHP builds now
include non-TS versions, and so does Zend Core.
If you interested in further improving performance, look at bytecode
caches such as Zend Platform or APC. It can be especially beneficial if
you use frameworks containing a lot of PHP classes.
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED] http://www.zend.com/
--- End Message ---
--- Begin Message ---
Zoltán Németh wrote:
>>>> I wrote a small sample-application once using PHP (with propel and
>>>> smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are
>>>> being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the
>>>> performance of the PHP version is much slower than the Java version.
>>> I think this is because Java is compiled once, PHP is compiled at every
>>> request...
>> Well, but using something like eAccelerator should compensate this,
>> shouldn't it? As far as I understand, scripts are being compiled and
>> then store in memory to access them faster.
>
> not exactly. it pre-compiles them to opcodes and stores the opcode
> blocks. the interpreter normally first pre-compiles the code to opcodes
> then runs the opcode. this pre-compilation can be cached with
> accelerators, that's how they increase performance.
But as far as I understand, java kinda does the same thing, doesn't it?
Java programs are being compiled into some intermediate language, and
this is being interpreted at runtime. So using an accelerator should
mimic the same setup for php.
Do you know any resource, describing how php works (like the thing about
compiling opcode, and stuff)? How does php handle simultaneous requests?
Are there multiple threads spawned?
--
... There are 10 kinds of people. Those who know binary code, and those
who don't.
--- End Message ---
--- Begin Message ---
But as far as I understand, java kinda does the same thing, doesn't it?
Java programs are being compiled into some intermediate language, and
this is being interpreted at runtime. So using an accelerator should
mimic the same setup for php.
Java is much less dynamic language than PHP (try doing $foo = $$bar in
Java :) which allows it to generate more low-level and more efficient
bytecode and also use JIT compiling to further improve its performance.
PHP opcodes is more high-level and not JIT-ed (unless somebody writes
JIT for PHP, which didn't happen yet :)
Do you know any resource, describing how php works (like the thing about
compiling opcode, and stuff)? How does php handle simultaneous requests?
Try these:
http://www.php.net/manual/en/internals.php
http://blog.libssh2.org/index.php?/archives/24-Extending-and-Embedding-PHP.html
Are there multiple threads spawned?
Depends on server API. ISAPI does, fastCGi doesn't.
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED] http://www.zend.com/
--- End Message ---
--- Begin Message ---
Stanislav Malyshev wrote:
>> But as far as I understand, java kinda does the same thing, doesn't it?
>> Java programs are being compiled into some intermediate language, and
>> this is being interpreted at runtime. So using an accelerator should
>> mimic the same setup for php.
>
> Java is much less dynamic language than PHP (try doing $foo = $$bar in
> Java :) which allows it to generate more low-level and more efficient
> bytecode and also use JIT compiling to further improve its performance.
> PHP opcodes is more high-level and not JIT-ed (unless somebody writes
> JIT for PHP, which didn't happen yet :)
ok, sounds reasonable.
>> Do you know any resource, describing how php works (like the thing about
>> compiling opcode, and stuff)? How does php handle simultaneous requests?
>
> Try these:
> http://www.php.net/manual/en/internals.php
> http://blog.libssh2.org/index.php?/archives/24-Extending-and-Embedding-PHP.html
ah, this saves my good-night-reading for today! :)
>> Are there multiple threads spawned?
>
> Depends on server API. ISAPI does, fastCGi doesn't.
OK; so for serving multiple concurrent clients ISAPI would sound to me
like the better choice, since it can use threads, or what would be the
advantage of using fastcgi?
--
... ERROR: CPU not found.
--- End Message ---
--- Begin Message ---
OK; so for serving multiple concurrent clients ISAPI would sound to me
like the better choice, since it can use threads, or what would be the
advantage of using fastcgi?
Non-threaded PHP is faster than threaded PHP, because it doesn't need to
do locks between threads and keep the thread context through the code,
etc. So FastCGI usually would be faster and also more stable since the
memory space is not shared. It forgoes some advantages of threaded
application, but overall it is faster.
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED] http://www.zend.com/
--- End Message ---
--- Begin Message ---
Stanislav Malyshev wrote:
>> OK; so for serving multiple concurrent clients ISAPI would sound to me
>> like the better choice, since it can use threads, or what would be the
>> advantage of using fastcgi?
>
> Non-threaded PHP is faster than threaded PHP, because it doesn't need to
> do locks between threads and keep the thread context through the code,
> etc. So FastCGI usually would be faster and also more stable since the
> memory space is not shared. It forgoes some advantages of threaded
> application, but overall it is faster.
OK, so I will give that a try. As far as I understand, I basically just
have to replace the association of ".php" to "php5isapi.dll" with
"php-cgi.exe"; and then set the global path to include my php-folder, right?
--
... ERROR: CPU not found.
--- End Message ---
--- Begin Message ---
OK, so I will give that a try. As far as I understand, I basically just
have to replace the association of ".php" to "php5isapi.dll" with
"php-cgi.exe"; and then set the global path to include my php-folder, right?
No, that probably would make it CGI, which is slow. For FastCGI, you
need FastCGI module for IIS. Zend Core contains one, and Microsoft has
its own here: http://www.iis.net/default.aspx?tabid=1000051
Also see:
http://blogs.iis.net/rickjames/archive/2007/04/19/fastcgi-tp2-unofficial-update-70419.aspx
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED] http://www.zend.com/
--- End Message ---
--- Begin Message ---
Hey all!
I'm in panic! I need a regex that returns true on strings containing
both 'update' and 'where 1 = 1'. Both must be case insensitive and there
might be spaces between the 1's and the '=', and there might not..
Some nitwit chose to build the database functions of the site I'm
working on so that if there's no where-statement, it goes with where 1 =
1.. Problem is, I have no access to the class library, except the
sqlExecute-function... so I need to protect it all from there. Also, I
have absolutely NO time whatsoever to learn regexes, since this shit
empties the table fields every half hour or so.
I'd really appreciate someone writing the perfect regex for me.
Thanks!
Mike
--- End Message ---
--- Begin Message ---
Here's a very simple one I just knocked out in a few seconds:
<?php
// The "i" after the pattern delimiter indicates a case-insensitive search
$SQLString='update atable set foobar=1 where 1=1';
if (preg_match("/update.*1(\s)?\=(\s)?1/i", $SQLString)) {
echo "A match was found.";
} else {
echo "A match was not found.";
}
?>
Mikael Grön wrote:
Hey all!
I'm in panic! I need a regex that returns true on strings containing
both 'update' and 'where 1 = 1'. Both must be case insensitive and
there might be spaces between the 1's and the '=', and there might not..
Some nitwit chose to build the database functions of the site I'm
working on so that if there's no where-statement, it goes with where 1
= 1.. Problem is, I have no access to the class library, except the
sqlExecute-function... so I need to protect it all from there. Also, I
have absolutely NO time whatsoever to learn regexes, since this shit
empties the table fields every half hour or so.
I'd really appreciate someone writing the perfect regex for me.
Thanks!
Mike
--- End Message ---
--- Begin Message ---
A little more precise to what you asked for:
<?php
// The "i" after the pattern delimiter indicates a case-insensitive search
$SQLString='update atable set foobar=1 where 1=1';
//$SQLString='update atable set foobar = 1 where 1 = 1';
if (preg_match("/update.*where\s1(\s)?\=(\s)?1/i", $SQLString)) {
echo "A match was found.";
} else {
echo "A match was not found.";
}
?>
Mikael Grön wrote:
Hey all!
I'm in panic! I need a regex that returns true on strings containing
both 'update' and 'where 1 = 1'. Both must be case insensitive and
there might be spaces between the 1's and the '=', and there might not..
Some nitwit chose to build the database functions of the site I'm
working on so that if there's no where-statement, it goes with where 1
= 1.. Problem is, I have no access to the class library, except the
sqlExecute-function... so I need to protect it all from there. Also, I
have absolutely NO time whatsoever to learn regexes, since this shit
empties the table fields every half hour or so.
I'd really appreciate someone writing the perfect regex for me.
Thanks!
Mike
--- End Message ---