-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbenchmark_multiplecomparison_strpos.php
More file actions
44 lines (32 loc) · 1.1 KB
/
benchmark_multiplecomparison_strpos.php
File metadata and controls
44 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
/** @noinspection AutoloadingIssuesInspection */
include "Collection.php";
$instances=2000000;
$variable = 'f';
for($s=0;$s<=10;$s++) {
// **********************************************************************************
$t1 = microtime(true);
for ($i = 0; $i < $instances; $i++) {
if ($variable === 'a' || $variable==='b' || $variable==='c') {
echo "it is not possible";
}
}
$t2 = microtime(true);
$table[$s]['multipleif'] = $t2 - $t1;
// **********************************************************************************
$t1 = microtime(true);
$str = '';
for ($i = 0; $i < $instances; $i++) {
if (strpos('abc',$variable)!==false) {
echo "it is not possible";
}
}
echo $str;
// note: $r=eval('ping("pong");'); return null
// note: $r=eval('return ping("pong");'); return 'pong'
$t2 = microtime(true);
$table[$s]['strpos'] = $t2 - $t1;
$table[$s]['percentage']=$table[$s]['multipleif']*100/$table[$s]['strpos'];
}
echo \mapache_commons\Collection::generateTable($table);