Mantis - Quercus
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
2198 | minor | always | 11-21-07 19:14 | 11-27-07 13:51 | |
|
|||||
Reporter: | koreth | Platform: | |||
Assigned To: | nam | OS: | |||
Priority: | normal | OS Version: | |||
Status: | closed | Product Version: | 3.1.4 | ||
Product Build: | Resolution: | fixed | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | 3.1.4 | ||
|
|||||
Summary: | 0002198: strtr() is very slow with an array of replacements | ||||
Description: |
If you pass more than one replacement string in an array, strtr() becomes horribly slow. <?php header('Content-type: text/plain'); $str = str_repeat("x\n", 10000); $start_time = microtime(true); $x = strtr($str, "\n", '\\n'); $end_time = microtime(true); print "simple strtr = " . ($end_time - $start_time) . "\n"; $start_time = microtime(true); $x = strtr($str, array("\n"=>'\\n')); $end_time = microtime(true); print "1-element array strtr = " . ($end_time - $start_time) . "\n"; $start_time = microtime(true); $x = strtr($str, array("\n"=>'\\n', "\r"=>'\\r')); $end_time = microtime(true); print "2-element array strtr = " . ($end_time - $start_time) . "\n"; $start_time = microtime(true); $x = strtr($str, array("\n"=>'\\n', "\r"=>'\\r', "&"=>'&')); $end_time = microtime(true); print "3-element array strtr = " . ($end_time - $start_time) . "\n"; $start_time = microtime(true); $x = strtr($str, array("\n"=>'\\n', "\r"=>'\\r', "&"=>'&', "a"=>"b")); $end_time = microtime(true); print "4-element array strtr = " . ($end_time - $start_time) . "\n"; Vanilla PHP output: simple strtr = 0.00012397766113281 1-element array strtr = 0.0010809898376465 2-element array strtr = 0.0010781288146973 3-element array strtr = 0.0010428428649902 4-element array strtr = 0.0010390281677246 Quercus output: simple strtr = 4.2999908328056335E-4 1-element array strtr = 0.0019129998981952667 2-element array strtr = 0.3932980000972748 3-element array strtr = 0.6140780001878738 4-element array strtr = 0.9110129997134209 |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
Notes | |||||
|
|||||
|
|