ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

90{
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}
benchTime()
const BENCH_CYCLES
global $utfCanonicalDecomp
Definition: UtfNormal.php:23
$i
Definition: disco.tpl.php:19
if(isset($_POST['submit'])) $form

References $data, $form, $i, $out, $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.

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 {
79 }
80 }
81}
benchmarkForm(&$u, &$data, $form)
if(! $in) print

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

+ Here is the call graph for this function:

◆ benchTime()

benchTime ( )

Definition at line 83 of file UtfNormalBench.php.

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

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.