Skip to content

Instantly share code, notes, and snippets.

@c9s
Created April 3, 2016 07:38
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 c9s/8cd230a5601cbe38439661adf3caca0d to your computer and use it in GitHub Desktop.
Save c9s/8cd230a5601cbe38439661adf3caca0d to your computer and use it in GitHub Desktop.
<?php
class StatusGetter {
protected $status;
public function __construct($status) {
$this->status = $status;
}
public function getStatus() {
return $this->status;
}
}
$a = new StatusGetter('success!');
$i = 1000000;
$startTime = microtime(true);
$status = $a->getStatus();
echo "#1 ", $status, "\n";
while ($i--) {
$status2 = $a->getStatus();
}
$endTime = microtime(true);
echo "#2 ", $status2, "\n";
echo ($endTime - $startTime) * 1000, "ms", PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment