|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-23 12:05 UTC] jdespatis at yahoo dot fr
[2008-01-23 12:08 UTC] jdespatis at yahoo dot fr
[2008-01-23 21:32 UTC] felipe@php.net
[2008-01-23 22:53 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 22:00:01 2025 UTC |
Description: ------------ I have a 36k xml file I launch preg_replace_callback on it, but php runs crazy 99% CPU Reproduce code: --------------- test case try this code with the 1087985.xml i give in attachment: the aim is to cut the string ended by \r or \n or \x0, and launch a specific function (protocol_analyse) on each message <?php function protocol_analyse($m) { echo "protocol_analyse:\n"; print_r($m); } $buff = file_get_contents("1087985.xml"); $start = microtime(true); $buff = preg_replace_callback("/([^\r\n\\x00]*)[\r\n\\x00]+/m", "protocol_analyse", $buff); $end = microtime(true); printf("Duration : %.2f", $end - $start); ?> Expected result: ---------------- I expect the function to returns quick, but 99% CPU taken Actual result: -------------- Duration : 133.00 sec which is very very slow