-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
56 lines (47 loc) · 1.25 KB
/
example.php
File metadata and controls
56 lines (47 loc) · 1.25 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
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/*
* This file is part of the FSB package.
*
* (c) Jitendra Adhikari <jiten.adhikary@gmail.com>
* <https://github.com/adhocore>
*
* Licensed under MIT license.
*/
use Ahc\Fsb\Bench;
require_once __DIR__ . '/src/Bench.php';
(new Bench)
// Set title: separate the benchmark functions with ` vs ` or ` | `.
->title('closure.strict | closure.loose | Compare->strict | Compare->loose | Compare::strict | Compare::loose')
// Number of iterations.
->iter(10000)
// Set the common input data for benchmarks.
// The data will be available to benchmarked functions in the order they are set here.
->data('1st', '2nd' /*, 3rd... */)
// Benchmark all the callables!
->run(
// As closure.
function ($first, $second /*, $third... */) {
echo $first === $second;
},
function ($first, $second) {
echo $first == $second;
},
// As instance method
[new Compare, 'strict'],
[new Compare, 'loose'],
// As static method
['Compare', 'strict'],
['Compare', 'loose']
// Add another callable (and append to title above)...
);
class Compare
{
public function strict($first, $second)
{
echo $first === $second;
}
public function loose($first, $second)
{
echo $first == $second;
}
}