Re: Timing PHP code

From: Date: Tue, 28 Nov 2000 13:50:31 +0000
Subject: Re: Timing PHP code
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-27596@lists.php.net to get a copy of this message
What about writing a PHP page that does the following: Open a file (passed as a parameter)... read it's content to a string... perform the following regexp: preg_replace( "/^(.*)$/", "\\1\necho microtime() . ':' . '\\1';\n" ); and then eval the resulting string. This will give you a microsecond timestamp on each line of your code... You can tweak it so instead of printing the timestamp, it writes it to a file, and the append some javascript code at the end of your page to open a popup window with the contents of the "timestamp log" file. You can also make it print a difference in time instead of absolute time. Of course this is a simplification... the preg_replace will have to look for single quotes on the original line and escape them. And there is a big problem with single line blocks (i.e., ifs without { and }), because the "echo..." line will be added after the if and thus replace the original line. It's not that easy to look for those special cases... but still doable... Or you can make sure all your blocks are surrounded by { and } "David Diaz i Torrico" <ddiaz@drac.com> wrote in message news:Pine.LNX.4.30.0011281337500.27743-100000@boix.drac.ct... > On Tue, 28 Nov 2000, Milan Mlynarcik wrote: > > > Ther's no any debuger at this time. I read article on Zend.Com that it will > > be added when apache 2.0 relased. > > I don't see the point of using apache to benchmark PHP, I don't want to > know the total time spent on page creation, what I want is the percentage > or weight of php functions/querys, my own functions or line by > line over the creation of the page. > > I just want to optimize slow functions / query's, but first I have to > locate them. > > Anyway, could you send me the URL of that article? I just can't find it, > and might be helpful. > > > > ----- Original Message ----- > > From: "David Diaz i Torrico" <ddiaz@drac.com> > > To: <php-general@lists.php.net> > > Sent: Tuesday, November 28, 2000 11:57 AM > > Subject: [PHP] Timing PHP code > > > > > > > > > > Hi, > > > > > > I'd like to know if there's *already* any program to time a php code line > > > by line since I want to track all the bottlenecks in a big php page > > > (thousands lines of code), and I wouldn't have to do it by setting > > > "breakpoints" to all the functions from scratch. > > > > > > > > > Any ideas or suggestions will be welcomed. > > > > > > > > > --- Sistemes - DRAC telemàtic --------------------- > > > c/ Transversal 226 - 08225 Terrassa > > > Tel: +34 93 736 48 30 > > > mailto:david@drac.com > > > ---------------------------------------------------- > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > --- Sistemes - DRAC telemàtic --------------------- > c/ Transversal 226 - 08225 Terrassa > Tel: +34 93 736 48 30 > mailto:david@drac.com > ---------------------------------------------------- > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#27596) next »