function _register_wrapper($namespace) { $fs = new FileSystem(new Connector(new ConnectorConfig(), new PathTranslator($namespace))); Assert::true(Wrapper::register($fs)); $context = stream_context_create(array('dir' => array('recursive' => true))); @rmdir('redis://', $context); }
<?php namespace Sallyx\StreamWrappers; include __DIR__ . '/../../vendor/autoload.php'; use Sallyx\StreamWrappers\Redis; use Sallyx\StreamWrappers\Wrapper; $fsDir = '/tmp/benchmark'; $redisDir = 'redis://'; $redisPath = 'www.sallyx.org/benchmark::'; $config = new Redis\ConnectorConfig(); $translator = new Redis\PathTranslator($redisPath); $connector = new Redis\Connector($config, $translator); $fs = new Redis\FileSystem($connector); Wrapper::register($fs); $benchmarks = [new FSBenchmark('Filesystem', $fsDir, \DIRECTORY_SEPARATOR), new FSBenchmark('Redis', $redisDir, '/')]; foreach ($benchmarks as $benchmark) { $benchmark->run(); echo PHP_EOL; } FSBenchmark::showResults($benchmarks); class FSBenchmark { const TEST_MKDIR = 'mkdir'; const TEST_RMDIR = 'rmdir'; const TEST_WRITE1 = 'write_a'; const TEST_WRITE2 = 'write_b'; const TEST_READ = 'read'; private static $allTests = [self::TEST_MKDIR, self::TEST_WRITE1, self::TEST_WRITE2, self::TEST_READ, self::TEST_RMDIR]; /** * @var name