ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
UtfNormalBench.php File Reference

Go to the source code of this file.

Functions

foreach($testfiles as $file=>
$desc) 
benchmarkTest (&$u, $filename, $desc)
 benchTime ()
 benchmarkForm (&$u, &$data, $form)

Variables

 if (isset($_SERVER['argv'])&&in_array( '--icu', $_SERVER['argv']))
const BENCH_CYCLES = 5
if(php_sapi_name()!= 'cli') $testfiles
 $normalizer = new UtfNormal

Function Documentation

benchmarkForm ( $u,
$data,
  $form 
)

Definition at line 88 of file UtfNormalBench.php.

References $data, $out, $utfCanonicalDecomp, BENCH_CYCLES, and benchTime().

Referenced by benchmarkTest().

{
#$start = benchTime();
for( $i = 0; $i < BENCH_CYCLES; $i++ ) {
$start = benchTime();
$out = $u->$form( $data, $utfCanonicalDecomp );
$deltas[] = (benchTime() - $start);
}
#$delta = (benchTime() - $start) / BENCH_CYCLES;
sort( $deltas );
$delta = $deltas[0]; # Take shortest time
$rate = intval( strlen( $data ) / $delta );
$same = (0 == strcmp( $data, $out ) );
printf( " %20s %6.1fms %12s bytes/s (%s)\n",
$form,
$delta*1000.0,
number_format( $rate ),
($same ? 'no change' : 'changed' ) );
return $out;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

foreach ($testfiles as $file=> $desc) benchmarkTest ( $u,
  $filename,
  $desc 
)

Definition at line 56 of file UtfNormalBench.php.

References $data, $filename, and benchmarkForm().

{
print "Testing $filename ($desc)...\n";
$data = file_get_contents( $filename );
$forms = array(
# 'placebo',
'cleanUp',
'toNFC',
# 'toNFKC',
# 'toNFD', 'toNFKD',
'NFC',
# 'NFKC',
# 'NFD', 'NFKD',
array( 'fastDecompose', 'fastCombiningSort', 'fastCompose' ),
# 'quickIsNFC', 'quickIsNFCVerify',
);
foreach( $forms as $form ) {
if( is_array( $form ) ) {
$str = $data;
foreach( $form as $step ) {
$str = benchmarkForm( $u, $str, $step );
}
} else {
benchmarkForm( $u, $data, $form );
}
}
}

+ Here is the call graph for this function:

benchTime ( )

Definition at line 83 of file UtfNormalBench.php.

Referenced by benchmarkForm().

{
$st = explode( ' ', microtime() );
return (float)$st[0] + (float)$st[1];
}

+ Here is the caller graph for this function:

Variable Documentation

$normalizer = new UtfNormal

Definition at line 48 of file UtfNormalBench.php.

if (php_sapi_name()!= 'cli') $testfiles
Initial value:
array(
'testdata/washington.txt' => 'English text',
'testdata/berlin.txt' => 'German text',
'testdata/bulgakov.txt' => 'Russian text',
'testdata/tokyo.txt' => 'Japanese text',
'testdata/young.txt' => 'Korean text'
)

Definition at line 41 of file UtfNormalBench.php.

const BENCH_CYCLES = 5

Definition at line 35 of file UtfNormalBench.php.

Referenced by benchmarkForm().

if(isset($_SERVER['argv'])&&in_array( '--icu', $_SERVER['argv']))

Definition at line 28 of file UtfNormalBench.php.