[ create a new paste ] login | about

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

PHP, pasted on Nov 19:
<?php

function chopExtension1($filename) {
    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    return preg_replace('/\.' . preg_quote($ext, '/') . '$/', '', $filename);
}

function chopExtension2($filename) {
    return substr($filename, 0, strrpos($filename, '.'));
}



$now1 = microtime();

foreach(range(1, 1000) as $i) {

	chopExtension1('bob.php');

}

$duration1 = microtime() - $now;



$now2 = microtime();

foreach(range(1, 1000) as $i) {


	chopExtension2('bob.php');

}
$duration2 = microtime() - $now2;

echo $duration1 . ' ' . $duration2;

echo 'difference => ' . ($duration1 - $duration2);


Output:
1
0.390031 0.001525difference => 0.388506


Create a new paste based on this one


Comments: