3 ms·
For comparison, PHP has mutable strings. Some totally unscientific averaged benchmarks (Atom D2700, PHP 5.4.4-14 amd64): $buff = ''; for ($i = 0; $i !=
by mappu 13y ago
For comparison, PHP has mutable strings. Some totally unscientific averaged benchmarks (Atom D2700, PHP 5.4.4-14 amd64):
$buff = '';
for ($i = 0; $i != 100000; ++$i) {
$buff .= $i;
}
Runs in about 0.06s
$buff = array();
for ($i = 0; $i != 100000; ++$i) {
$buff[] = $i;
}
$ret = implode('', $buff);
Runs slower, in about 0.10s
$ret = implode('', range(0, 100000));
Takes roughly the same time, 0.10s
- deleted 13y ago[deleted]