Created
September 8, 2013 20:19
-
-
Save samdark/6488060 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
class Wrapper { | |
private $value; | |
private $isHit; | |
function __construct($isHit, $value) | |
{ | |
$this->isHit = $isHit; | |
$this->value = $value; | |
} | |
/** | |
* @param mixed $isHit | |
*/ | |
public function setIsHit($isHit) | |
{ | |
$this->isHit = $isHit; | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getIsHit() | |
{ | |
return $this->isHit; | |
} | |
/** | |
* @param mixed $value | |
*/ | |
public function setValue($value) | |
{ | |
$this->value = $value; | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getValue() | |
{ | |
return $this->value; | |
} | |
} | |
$start = microtime(true); | |
function get_cache_value() { | |
$value = rand(0, 100).'test'; | |
return new Wrapper(true, $value); | |
} | |
$results = array(); | |
for ($i=0; $i<1000; $i++) { | |
$results[] = get_cache_value(); | |
} | |
printf("Done in: %f s\n", microtime(true) - $start)."\n"; | |
printf("Memory used: %d KB\n", memory_get_peak_usage(true)/1024)."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Done in: 0.005024 s
Memory used: 512 KB