php test1 category-1 test2 category count 100000 for microtime TRUE co

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?php
$test1 = '/category-1/';
$test2 = '/category/1/';
$count = 100000;
for($i = 0, $t = microtime(TRUE); $i < $count; $i++) {
preg_match('/([a-z]+)\-([0-9]+)/i', $test1, $result);
}
echo "preg_match execution " . (microtime(TRUE) - $t) . "\n";
for($i = 0, $t = microtime(TRUE); $i < $count; $i++) {
$result = explode('/', $test2);
}
echo "explode execution " . (microtime(TRUE) - $t) . "\n";