File tree 3 files changed +59
-1
lines changed
3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace drupol \phptree \benchmarks ;
6
+
7
+ abstract class AbstractBench
8
+ {
9
+ /**
10
+ * @return array
11
+ */
12
+ public function getData ()
13
+ {
14
+ return \range (1 , 100 );
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace drupol \phptree \benchmarks ;
6
+
7
+ use drupol \phptree \Node \ValueNode ;
8
+ use PhpBench \Benchmark \Metadata \Annotations \BeforeMethods ;
9
+
10
+ /**
11
+ * @Groups({"drupol/phptree"})
12
+ * @BeforeMethods({"initObject"})
13
+ */
14
+ class DrupolPhpTreeBench extends AbstractBench
15
+ {
16
+ /**
17
+ * @var \drupol\phptree\Node\NodeInterface
18
+ */
19
+ private $ tree ;
20
+
21
+ /**
22
+ * Init the object.
23
+ */
24
+ public function initObject ()
25
+ {
26
+ }
27
+
28
+ /**
29
+ * @Revs({1, 100, 1000})
30
+ * @Iterations(5)
31
+ * @Warmup(10)
32
+ */
33
+ public function benchHash ()
34
+ {
35
+ $ this ->tree = new ValueNode ();
36
+
37
+ foreach ($ this ->getData () as $ value ) {
38
+ $ this ->tree ->add (new ValueNode ($ value ));
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change 45
45
},
46
46
"autoload-dev" : {
47
47
"psr-4" : {
48
- "drupol\\ phptree\\ tests\\ " : " tests/src/"
48
+ "drupol\\ phptree\\ tests\\ " : " tests/src/" ,
49
+ "drupol\\ phptree\\ benchmarks\\ " : " benchmarks/"
49
50
}
50
51
},
51
52
"config" : {
You can’t perform that action at this time.
0 commit comments