[ create a new paste ] login | about

Link: http://codepad.org/KGqtWbxO    [ raw code | output | fork ]

PHP, pasted on Oct 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?

$var = implode(',', range(1,9999));

$time = microtime(true);

for ($i = 0; $i < 100; $i++) {
	$count = substr_count($var, ',') + 1;
}

printf("TIME: %0.2d\n", (microtime(true) - $time) * 1000);

$time = microtime(true);

for ($i = 0; $i < 100; $i++) {
	$count = count(explode(',', $var));
}

printf("TIME: %0.2d\n", (microtime(true) - $time) * 1000);


Output:
1
2
TIME: 35
TIME: 2394


Create a new paste based on this one


Comments: