views:

44

answers:

1

That is a common question, but I would like to hear some expert opinions.

I'm starting a new PHP project that I would like to keep an eye on. What I want to track is:

  • included files - frameworks that use index.php and bootstrap files and load many files on page load
  • sql dumps - this one is easier because most frameworks have DB logging (as well as ORM frameworks and so on)
  • time load
  • memory tracking - memory statistics for different areas of the project
  • crash tests - maximum request per second for a given page

There are probably some benchmarking and debugging facilities that could be used for some purpose. What are the best practices for these parameters?

A: 

a good and commonly used benchmark tool is siege. install it using your package manager (like apt-get install siege) and use it like this: siege -b -c 40 http://yoursite.com -b is benchmarking (no delays), -c is concurrent threads.

i think by time load you mean page generation time. well siege displays this as well but you can just use microtime(true) at the beginning and end of your bootstrap file and calculate the difference.

for debugging and statistics you can use DBG or xdebug, both very good tools. file includes can be measured using iostat or fifo.

but the best thing would be to put measure functions in wrapper functions that handle the jobs. most frameworks have central points to hook profilers in.

last but not least check out the php function memory_get_usage

Joe Hopfgartner
This is a good answer which covers most of the popular tools. However I'm working with different frameworks and systems and I'm trying not to hack something in the before and after phases and searching for something more automated or on lower level. Most frameworks however have similar functions in helper classes.
Mario Peshev
maby you wanna have a look at advanced php debug here http://www.php.net/manual/en/book.apd.php
Joe Hopfgartner