| Anonymous | Login | Signup for a new account | 11-03-2025 15:10 PST |
| Main | My View | View Issues | Change Log | Docs |
| Viewing Issue Advanced Details [ Jump to Notes ] | [ View Simple ] [ Issue History ] [ Print ] | ||||||||
| ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
| 0002198 | [Quercus] | minor | always | 11-21-07 19:14 | 11-27-07 13:51 | ||||
| Reporter | koreth | View Status | public | ||||||
| Assigned To | nam | ||||||||
| Priority | normal | Resolution | fixed | Platform | |||||
| Status | closed | OS | |||||||
| Projection | none | OS Version | |||||||
| ETA | none | Fixed in Version | 3.1.4 | Product Version | 3.1.4 | ||||
| Product Build | |||||||||
| 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 | |||||||||
| Attached Files | |||||||||
|
|
|||||||||
| Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed. 26 unique queries executed. |