Skip to content

Instantly share code, notes, and snippets.

@nikic
Created May 14, 2019 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikic/f592686c75d8d34d82ddc5900b598199 to your computer and use it in GitHub Desktop.
Save nikic/f592686c75d8d34d82ddc5900b598199 to your computer and use it in GitHub Desktop.
<?php
class A {
public $pub = 1;
protected $prot = 2;
private $priv = 3;
}
$n = 10000000;
$a = new A;
$t = microtime(true);
for ($i = 0; $i < $n; $i++) {
$x = (array) $a;
}
var_dump(microtime(true) - $t);
$t = microtime(true);
for ($i = 0; $i < $n; $i++) {
$x = get_mangled_object_vars($a);
}
var_dump(microtime(true) - $t);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment