Can be reproduced arbitrarily, but the reprint must be marked original author Charlee, the original link http://tech.idv2.com/2006/11/23/javascript-strreplace-benchmark/and this statement
I benchmark these two functions and found that the efficiency of the new functions is about 1.4 times times that of the original function. While not as efficient as expected, the efficiency should be increased when more strings are being replaced.
The test method is to perform two functions 100 times for a 2048-byte long string, taking its execution time. The following is the result of 10 tests. Totxt_1 for the usual practice, totxt_2 as clear method.
Totxt_1 (MS) |
Totxt_2 (MS) |
Totxt_1/totxt_2 |
1609 |
160° |
75% |
2250 |
1547 |
69% |
1672 |
1313 |
79% |
1813 |
1250 |
69% |
1844 |
1219 |
66% |
2063 |
1421 |
69% |
2031 |
1172 |
58% |
1797 |
1360 |
76% |
2015 |
1281 |
64% |
1860 |
1500 |
81% |
The test program is here http://img.jb51.net/online/javascript-benchmark/benchmark.htm