$values = array(); for ($iterator = 0; $iterator < $operations; $iterator++) { $values[sprintf('%020s', $iterator)] = sha1($iterator); } \Amp\run(function () use(&$i, $values) { $memcached = new \Edo\Memcached(); $memcached->addServer('tcp://127.0.0.1', 11211); $start = microtime(true); foreach ($values as $k => $v) { $stats = (yield $memcached->set($k, $v, 3600)); } $time = microtime(true) - $start; echo "amp-memcached set: {$time}\n"; $start = microtime(true); foreach ($values as $k => $v) { $stats = (yield $memcached->get($k)); } $time = microtime(true) - $start; echo "amp-memcached get: {$time}\n"; \Amp\stop(); }); if (extension_loaded('memcache')) { $memached = new Memcache(); $memached->addServer('127.0.0.1', 11211); $start = microtime(true); foreach ($values as $k => $v) { $memached->set($k, $v, 3600); } $time = microtime(true) - $start; echo "memcache set: {$time}\n"; $start = microtime(true);
require __DIR__ . '/../vendor/autoload.php'; $i = 0; \Amp\repeat(function () use(&$i) { echo "\n{$i} iterations"; $i = 0; }, 1000); \Amp\once(function () { \Amp\stop(); }, 5000); \Amp\once(function () { \Amp\stop(); }, 10000); echo "##### SET OP/S"; \Amp\run(function () use(&$i) { $memcached = new \Edo\Memcached(); $memcached->addServer('tcp://127.0.0.1', 11211); while (true) { $stats = (yield $memcached->set('key', 'value_key')); $i++; } }); echo "\n##### GET OP/S"; \Amp\run(function () use(&$i) { $memcached = new \Edo\Memcached(); $memcached->addServer('tcp://127.0.0.1', 11211); while (true) { $stats = (yield $memcached->get('key')); $i++; } });