Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

silly me, i had the arguments to str_replace in the wrong order. we'r…

…e still

a tad slower, but not 12x slower like it showed when zend wasn't actually doing any work.
  • Loading branch information...
commit 714d59c21d75e894ebfbdcefd3f73274e3db724b 1 parent d880ff0
@weyrick authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 benchmarks/tests/str_replace.php
View
13 benchmarks/tests/str_replace.php
@@ -2,15 +2,15 @@
$small = "ABCDEFGHIJKLMNOPQRSTUVQXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}";
for ($i=65; $i<126; $i++) {
- echo str_replace($small, chr($i),'1');
+ echo str_replace(chr($i),'1',$small);
}
for ($i=65; $i<126; $i++) {
- echo str_replace($small, chr($i),'foo');
+ echo str_replace(chr($i),'foo',$small);
}
for ($i=65; $i<126; $i++) {
- echo str_replace($small, chr($i),'fooooooooooooooooooooooooooooooooooooooooooooooooooooo');
+ echo str_replace(chr($i),'fooooooooooooooooooooooooooooooooooooooooooooooooooooo',$small);
}
$big =<<<FOO
@@ -35,9 +35,10 @@
FOO;
for ($i=0; $i<1000; $i++) {
- $a = str_replace($big, 'sit', 'a');
- $a = str_replace($big, 'sit', 'foo');
- $a = str_replace($big, 'sit', 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo');
+ $a = str_replace('sit', 'a', $big);
+ echo $a;
+ $a = str_replace('sit', 'foo', $big);
+ $a = str_replace('sit', 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo',$big);
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.