- number_format: documentation ( source)
- hrtime: documentation ( source)
- printf: documentation ( source)
<?php
// start engines;
for($i=0;$i++<2;)number_format(hrtime(true),5);test_1('hi');test_2('hi');
function test_1( $string ) {}
function test_2( string $string ) {}
$t = hrtime(true);
for ( $i = 0; ++$i < 1e6; ) test_1( 'hi' );
echo 'untyped: ', $a=number_format( (hrtime(true)-$t)/1e9,5),"s\n";
$t = hrtime(true);
for ( $i = 0; ++$i < 1e6; ) test_2( 'hi' );
echo 'typed: ', $b=number_format( (hrtime(true)-$t)/1e9,5),"s\n";
printf( 'Typed is %d%% slower.', (1-($a/$b))*100 );