File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 5
5
use MongoDB \Benchmark \BaseBench ;
6
6
use MongoDB \BSON \Document ;
7
7
use PhpBench \Attributes \BeforeMethods ;
8
+ use stdClass ;
8
9
9
10
use function file_get_contents ;
10
11
use function iterator_to_array ;
@@ -49,6 +50,15 @@ public function benchToPHPObject(): void
49
50
self ::$ document ->toPHP ();
50
51
}
51
52
53
+ public function benchToPHPObjectViaIteration (): void
54
+ {
55
+ $ object = new stdClass ();
56
+
57
+ foreach (self ::$ document as $ key => $ value ) {
58
+ $ object ->$ key = $ value ;
59
+ }
60
+ }
61
+
52
62
public function benchToPHPArray (): void
53
63
{
54
64
self ::$ document ->toPHP (['root ' => 'array ' ]);
Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ public function benchToPHPArray(): void
55
55
self ::$ array ->toPHP ();
56
56
}
57
57
58
+ public function benchToPHPArrayViaIteration (): void
59
+ {
60
+ $ array = [];
61
+
62
+ foreach (self ::$ array as $ key => $ value ) {
63
+ $ array [$ key ] = $ value ;
64
+ }
65
+ }
66
+
58
67
public function benchIteration (): void
59
68
{
60
69
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedForeach
You can’t perform that action at this time.
0 commit comments