Skip to content

Instantly share code, notes, and snippets.

@samdark
Created September 8, 2013 20:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save samdark/6488060 to your computer and use it in GitHub Desktop.
<?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";
@samdark
Copy link
Author

samdark commented Sep 10, 2013

Done in: 0.005024 s
Memory used: 512 KB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment