ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 89 of file UtfNormalBench.php.

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

Referenced by benchmarkTest().

90 {
91  global $utfCanonicalDecomp;
92  #$start = benchTime();
93  for ($i = 0; $i < BENCH_CYCLES; $i++) {
94  $start = benchTime();
95  $out = $u->$form($data, $utfCanonicalDecomp);
96  $deltas[] = (benchTime() - $start);
97  }
98  #$delta = (benchTime() - $start) / BENCH_CYCLES;
99  sort($deltas);
100  $delta = $deltas[0]; # Take shortest time
101 
102  $rate = intval(strlen($data) / $delta);
103  $same = (0 == strcmp($data, $out));
104 
105  printf(
106  " %20s %6.1fms %12s bytes/s (%s)\n",
107  $form,
108  $delta * 1000.0,
109  number_format($rate),
110  ($same ? 'no change' : 'changed')
111  );
112  return $out;
113 }
global $utfCanonicalDecomp
Definition: UtfNormal.php:21
$start
Definition: bench.php:8
if(isset($_POST['submit'])) $form
benchTime()
$i
Definition: disco.tpl.php:19
const BENCH_CYCLES
$data
Definition: bench.php:6
+ 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, $form, $step, 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)
if(isset($_POST['submit'])) $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
$filename
Definition: buildRTE.php:89
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ benchTime()

benchTime ( )

Definition at line 83 of file UtfNormalBench.php.

Referenced by benchmarkForm().

84 {
85  $st = explode(' ', microtime());
86  return (float) $st[0] + (float) $st[1];
87 }
+ 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']))

Definition at line 28 of file UtfNormalBench.php.