79136468

Date: 2024-10-29 09:11:10
Score: 1
Natty:
Report link

@magallanes script on PHP 8.3.13 (built: Oct 22 2024)

arrays: 0.079897880554199
memory: 428536

Array
(
    [aaa] => aaa
    [bbb] => bbb
    [ccc] => aaabbb
)

-------------------------

arrays: 0.059076070785522
memory: 148128

SomeClass Object
(
    [aaa] => aaa
    [bbb] => bbb
    [ccc] => aaabbb
)

-------------------------

arrays: 0.06840991973877
memory: 468032

stdClass Object
(
    [aaa] => aaa
    [bbb] => bbb
    [ccc] => aaabbb
)

But what i have noticed, if i add types and add Setters and Getters to the class. If i use them instead of the direct variable calls, there is a drastic increase of time.

arrays: 0.085529804229736
memory: 148128

SomeClass Object
(
    [aaa] => aaa
    [bbb] => bbb
    [ccc] => aaabbb
)

-------------------------

arrays: 0.29699301719666
memory: 148032

SomeClass Object (Getters and Setters)
(
    [aaa] => aaa
    [bbb] => bbb
    [ccc] => aaabbb
)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @magallanes
  • Low reputation (1):
Posted by: MSBluhm