Created
February 19, 2024 14:17
-
-
Save jdv/d44522b6b80cf07f8f60e3425a14290f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jdv@jdv-lap2:~$ cat test.php | |
<?php | |
class Action | |
{ | |
public $name; public $age; | |
public function __construct($name, $age) { | |
$this->name = $name; $this->age = $age; | |
} | |
public function execute () { | |
return ['name' => $this->name, 'age' => $this->age]; | |
} | |
} | |
$name = 'Tim'; $age = 12; | |
foreach (range(1, 1000000) as $i) { | |
$user = (new Action($name, $age))->execute(); | |
$user = null; | |
} | |
?> | |
jdv@jdv-lap2:~$ time php test.php | |
real 0m0.094s | |
user 0m0.082s | |
sys 0m0.012s | |
jdv@jdv-lap2:~$ time php test.php | |
real 0m0.094s | |
user 0m0.085s | |
sys 0m0.008s | |
jdv@jdv-lap2:~$ time php test.php | |
real 0m0.094s | |
user 0m0.090s | |
sys 0m0.004s | |
jdv@jdv-lap2:~$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment