public function run() { $this->initCache(); $repeats = $this->getRepeats(); $bar = new CliProgressBar($repeats); $data = range(0, 99); Cache::setAdapter(MemcacheAdapter::instance()); for ($i = 1; $i <= $repeats; ++$i) { $key = sha1(uniqid()); Timer::start(); Cache::set($key, $data); Timer::stop(); $bar->update($i); } $this->addResult('Memcache', Timer::get()); $bar = new CliProgressBar($repeats); Timer::reset(); Cache::setAdapter(MemcachedAdapter::instance()); for ($i = 1; $i <= $repeats; ++$i) { $key = sha1(uniqid()); Timer::start(); Cache::set($key, $data); Timer::stop(); $bar->update($i); } $this->addResult('Memcached', Timer::get()); Cache::clear(); }
public static final function run() { self::initCache(); $repeats = self::getRepeats(); $bar = new CliProgressBar($repeats); $key = md5('adfjkjkang'); $data = range(0, 10); Cache::setAdapter(MemcacheAdapter::instance()); Cache::set($key, $data); for ($i = 1; $i <= $repeats; ++$i) { Timer::start(); Cache::get($key); Timer::stop(); $bar->update($i); } self::addResult('Memcache', Timer::get()); $bar = new CliProgressBar($repeats); Cache::setAdapter(MemcachedAdapter::instance()); Timer::reset(); for ($i = 1; $i <= $repeats; ++$i) { Timer::start(); Cache::get($key); Timer::stop(); $bar->update($i); } self::addResult('Memcached', Timer::get()); Cache::clear(); }