开发者

PHP Performance Metrics

开发者 https://www.devze.com 2022-12-27 01:37 出处:网络
I am currently developing a PHP MVC Framework for a personal project.While I am developing the framework I am interested to see any notable performance by implementing different techniques for optimiz

I am currently developing a PHP MVC Framework for a personal project. While I am developing the framework I am interested to see any notable performance by implementing different techniques for optimization. I have implemented a crude BenchMark class that logs mircotime.

The problem is I have no frame of reference for execution times. I am very near the beginnig of this project with a database connection and a few queries but no output (bar some debugging text and BenchMark log). I have a current execution time of 0.01917 seconds.

I was expecting this to be lower but as I said before I have no frame of reference. I appreciate there are many variables to take into account when juding performance but I am hoping to find some sort of metric to

a) techniques to measure performance for example requests per second and

b) compare results for example; how a "moderately" sized PHP application on a "standard" webserver will perform. I appreciate "moderately" and "standard" are very subjective words so perhaps a table of known execution times for a particular application (eg StackOverFlow's executing time).

What are other techniques of measuring performance are there other than execution time?

When looking at MVC Framework Performance Comparisom it talks about Requests Per Second (RPS). How is this calculated? I am guessing with my current execution time of 0.01917 seconds can handle 52 RPS (= 1 / 0.01917 ). This seems t开发者_JAVA百科o be significantly lower than that quoted on the graph especially when you consider my current limited funcitonality.


To benchmark a certain page, use ab. To benchmark a load of pages on the server, try siege.

However... both of those are still mostly artificial tests. I personally add some extra logs too.

  • Page load time in the webserver (or proxy, whatever)
  • Slow query logging in the database
  • Query count logging per page too if possible, that way you'll know how heavy your pages are ;)


You can use xdebug to profile your code. But you are optimizing way too early in the development process. Just the act of calling microtime is going to slow things down since it has to make a call out to the system (outside the PHP engine). Every include, object creation, connection to another resource (i.e. database) is going to add a lot of overhead, relatively speaking.

If you design your system to be very cache friendly, then you don't have to execute code. For example, WordPress is very slow. About 15 pages/sec on a decent web server. It does a lot of includes and runs a lot of code. But add the SuperCache plugin and performance increases 10x. It works by creating a cache file and using some Apache rules so PHP doesn't have to be run at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消