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.

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

Referenced by benchmarkTest().

87  {
88  global $utfCanonicalDecomp;
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 }
global $utfCanonicalDecomp
Definition: UtfNormal.php:21
benchTime()
const BENCH_CYCLES
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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.

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

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)
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
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ benchTime()

benchTime ( )

Definition at line 82 of file UtfNormalBench.php.

Referenced by benchmarkForm().

82  {
83  $st = explode( ' ', microtime() );
84  return (float)$st[0] + (float)$st[1];
85 }
+ 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:
'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'
)
Create styles array
The data for the language used.

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']))

Definition at line 28 of file UtfNormalBench.php.