How to track project statistics (included pages, sql dumps, memory) in PHP?
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 开发者_StackOverflow社区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 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
精彩评论