thinkphp Performance Tuning

The development process, sometimes in order to test the performance, often need to debug a piece of code running time or memory usage overhead, the system provides a G method can easily get run time and memory usage of a range. E.g:

Jefferies Lianhua marble platform marble platform test procedures

  1. G('begin');
  2. // ...其他代码段
  3. G('end');
  4. // ...也许这里还有其他代码
  5. // 进行统计区间
  6. echo G('begin','end').'s';

G ( 'begin', 'end') represents the position to begin the execution time statistics end position (in seconds), must begin an already labeled position, end position if this time has not been marked, are automatically the current position of the end mark tag, similar to the output results:0.0056s

The default statistical accuracy is four decimal places, if they feel the statistical accuracy is not enough, you can also set the example:

  1. G('begin','end',6).'s';

The output may become:0.005587s

If your environment supports memory usage statistics, you can also use the method of interval G memory overhead statistics (in kb), for example:

  1. echo G('begin','end','m').'kb';

The third parameter m for memory overhead for statistics, the output result may be:625kb

Similarly, if the end tag is not marked, it will automatically end the current location of the first flag label.

If the environment does not support memory statistics, the parameter is invalid, the interval will still be run-time statistics.

Guess you like

Origin www.cnblogs.com/furuihua/p/11834819.html