Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = realpath($input->getOption('path'));
     $recursive = $input->getOption('recursive');
     $outputFile = $input->getOption('storage');
     $size = (int) $input->getOption('size');
     $length = (int) $input->getOption('length');
     $crawler = new FileCrawler($path, $recursive);
     $storage = new FileStorage($outputFile);
     $structure = new RedBlackSearchTree($storage, $size, $length);
     $crawler->walk([$structure, 'insert']);
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = realpath($input->getOption('path'));
     $recursive = $input->getOption('recursive');
     $outputFile = $input->getOption('storage');
     $size = (int) $input->getOption('size');
     $length = (int) $input->getOption('length');
     $c1 = (int) $input->getOption('c1');
     $c2 = (int) $input->getOption('c2');
     $crawler = new FileCrawler($path, $recursive);
     $storage = new FileStorage($outputFile);
     $structure = new QuadraticHashTable($storage, $size, $length);
     $structure->hashWithModifiers($c1, $c2);
     $crawler->walk([$structure, 'insert']);
 }
Exemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputFile = realpath($input->getArgument('storage'));
     $size = (int) $input->getOption('size');
     $length = (int) $input->getOption('length');
     $path = $input->getOption('path');
     $recursive = $input->getOption('recursive');
     $c1 = $input->getOption('c1');
     $c2 = $input->getOption('c2');
     $storage = new FileStorage($outputFile, 'r');
     $crawler = new FileCrawler($path, $recursive);
     $structure = new QuadraticHashTable($storage, $size, $length);
     $structure->hashWithModifiers($c1, $c2);
     $start = microtime(true);
     $n = 0;
     $crawler->walk(function ($file) use($structure, $output, &$n) {
         $n++;
         step();
         $node = $structure->search($file);
         step();
         if ($node === null) {
             step();
             return $output->writeln("<error>{$file} was not found!</error>");
         }
         step();
         $count = $structure->value($node);
         step();
         if ($count > 1) {
             step();
             return $output->writeln("<info>{$file} occurs {$count} times</info>");
         }
         step();
         return $output->writeln("{$file} occurs only once");
     });
     $time = microtime(true) - $start;
     $steps = step();
     $output->writeln(str_repeat('-', 15));
     $output->writeln(sprintf('Executed in %.3f µs', $time));
     $output->writeln("Steps executed {$steps}");
     $output->writeln("For {$n} files");
 }