ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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 88 of file UtfNormalBench.php.

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

Referenced by benchmarkTest().

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

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

56  {
57  print "Testing $filename ($desc)...\n";
58  $data = file_get_contents( $filename );
59  $forms = array(
60 # 'placebo',
61  'cleanUp',
62  'toNFC',
63 # 'toNFKC',
64 # 'toNFD', 'toNFKD',
65  'NFC',
66 # 'NFKC',
67 # 'NFD', 'NFKD',
68  array( 'fastDecompose', 'fastCombiningSort', 'fastCompose' ),
69 # 'quickIsNFC', 'quickIsNFCVerify',
70  );
71  foreach( $forms as $form ) {
72  if( is_array( $form ) ) {
73  $str = $data;
74  foreach( $form as $step ) {
75  $str = benchmarkForm( $u, $str, $step );
76  }
77  } else {
78  benchmarkForm( $u, $data, $form );
79  }
80  }
81 }
benchmarkForm(&$u, &$data, $form)
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ benchTime()

benchTime ( )

Definition at line 83 of file UtfNormalBench.php.

Referenced by benchmarkForm().

83  {
84  $st = explode( ' ', microtime() );
85  return (float)$st[0] + (float)$st[1];
86 }
+ Here is the caller graph for this function:

Variable Documentation

◆ $normalizer

$normalizer = new UtfNormal

Definition at line 48 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 41 of file UtfNormalBench.php.

◆ BENCH_CYCLES

const BENCH_CYCLES 5

Definition at line 35 of file UtfNormalBench.php.

Referenced by benchmarkForm().

◆ if

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

Definition at line 28 of file UtfNormalBench.php.