ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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()

benchmarkForm ( $u,
$data,
  $form 
)

Definition at line 87 of file UtfNormalBench.php.

87 {
89 #$start = benchTime();
90 for( $i = 0; $i < BENCH_CYCLES; $i++ ) {
91 $start = benchTime();
92 $out = $u->$form( $data, $utfCanonicalDecomp );
93 $deltas[] = (benchTime() - $start);
94 }
95 #$delta = (benchTime() - $start) / BENCH_CYCLES;
96 sort( $deltas );
97 $delta = $deltas[0]; # Take shortest time
98
99 $rate = intval( strlen( $data ) / $delta );
100 $same = (0 == strcmp( $data, $out ) );
101
102 printf( " %20s %6.1fms %12s bytes/s (%s)\n",
103 $form,
104 $delta*1000.0,
105 number_format( $rate ),
106 ($same ? 'no change' : 'changed' ) );
107 return $out;
108}
benchTime()
const BENCH_CYCLES
global $utfCanonicalDecomp
Definition: UtfNormal.php:23

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

Referenced by benchmarkTest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ benchmarkTest()

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

Definition at line 55 of file UtfNormalBench.php.

55 {
56 print "Testing $filename ($desc)...\n";
57 $data = file_get_contents( $filename );
58 $forms = array(
59# 'placebo',
60 'cleanUp',
61 'toNFC',
62# 'toNFKC',
63# 'toNFD', 'toNFKD',
64 'NFC',
65# 'NFKC',
66# 'NFD', 'NFKD',
67 array( 'fastDecompose', 'fastCombiningSort', 'fastCompose' ),
68# 'quickIsNFC', 'quickIsNFCVerify',
69 );
70 foreach( $forms as $form ) {
71 if( is_array( $form ) ) {
72 $str = $data;
73 foreach( $form as $step ) {
74 $str = benchmarkForm( $u, $str, $step );
75 }
76 } else {
77 benchmarkForm( $u, $data, $form );
78 }
79 }
80}
benchmarkForm(&$u, &$data, $form)
if(! $in) print
foreach($_REQUEST as $var) foreach(array('_POST'=> 'HTTP_POST_VARS', '_GET'=> 'HTTP_GET_VARS', '_COOKIE'=> 'HTTP_COOKIE_VARS', '_SERVER'=> 'HTTP_SERVER_VARS', '_ENV'=> 'HTTP_ENV_VARS', '_FILES'=> 'HTTP_POST_FILES') as $array=> $other) $step
Definition: cssgen.php:155

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

+ Here is the call graph for this function:

◆ benchTime()

benchTime ( )

Definition at line 82 of file UtfNormalBench.php.

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

Referenced by benchmarkForm().

+ Here is the caller graph for this function:

Variable Documentation

◆ $normalizer

$normalizer = new UtfNormal

Definition at line 47 of file UtfNormalBench.php.

◆ $testfiles

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 40 of file UtfNormalBench.php.

◆ BENCH_CYCLES

const BENCH_CYCLES 5

Definition at line 34 of file UtfNormalBench.php.

Referenced by benchmarkForm().

◆ if

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

Definition at line 28 of file UtfNormalBench.php.