Windows下:apache+php
递归时间: 1290次 0.0127840042114 times
非递归时间:1290次 0.00402212142944 times
Linux下:nginx+php
递归时间: 22290次 0.0981810092926 times
非递归时间:22290次 0.0421569347382 times
在Windows下,是我自己的机器,关于如何配置,让递归层数更大,我还没研究明白到底是哪里的配置有关,但是我相信是APACHE的配置关系到的. 我自己的机器,最大层数就是1290次.
相信是配置优化的问题.
PHP.INI配置
memory_limit = 1000M ; Maximum amount of memory a script may consume (128MB)
该配置确实影响递归层数,因为这是要分配内存的大小.如果超出,会报PHP的超出内存的错误.
但是设置为以上参数时
超出1290次后,我的APACHE会报如下错误:
[Tue Nov 17 11:20:17 2009] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Tue Nov 17 11:20:17 2009] [notice] Apache/2.2.4 (Win32) PHP/5.2.5 configured -- resuming normal operations
[Tue Nov 17 11:20:17 2009] [notice] Server built: Jan 9 2007 23:17:20
[Tue Nov 17 11:20:17 2009] [notice] Parent: Created child process 1872
[Tue Nov 17 11:20:18 2009] [notice] Child 1872: Child process is running
[Tue Nov 17 11:20:18 2009] [notice] Child 1872: Acquired the start mutex.
[Tue Nov 17 11:20:18 2009] [notice] Child 1872: Starting 250 worker threads.
[Tue Nov 17 11:20:18 2009] [notice] Child 1872: Starting thread to listen on port 80.
如果有高手知道这个,请告诉我,非常感谢
无论是什么情况下,通过测试已经知道,PHP的递归,效率确实比普通循环低很多.
请斟酌后再用.
递归:
|
非递归:
|