nauxliu / opencc4php

简繁体转换 PHP 扩展
MIT License
458 stars 85 forks source link

多次调用php-fpm超时 #19

Closed jackwu365 closed 8 years ago

jackwu365 commented 8 years ago

$od = opencc_open("s2twp.json"); //传入配置文件名 $text = opencc_convert("我鼠标哪儿去了。", $od); echo $text; opencc_close($od);

一个页面多次调用,会出现php-fpm 超时。。。

PHP 5.4.30 (cli) (built: Jul 29 2014 23:43:29) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

pkujhd commented 8 years ago

我在php5.5.15上测试了执行这个循环30次,耗时1s左右正常(linux vm,E5620 @ 2.40GHz, 1core 4GMem) ,因为opencc_open这个调用要打开一个4M左右的文件, 这个步骤非常的消耗资源. 不知道你遇到的情况是什么样的, 如果是执行了几百次循环的话,超时也是正常的.

bclow commented 8 years ago

我們測試過這個PR (https://github.com/NauxLiu/opencc4php/pull/21) 會避免call opencc_open()多次的問題