示例#1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = Config::getInstance();
     $times = $input->getOption('times');
     if ($times < 1) {
         $output->writeln("<error>benchmark {$times} is too small</error>");
         return;
     }
     $type = $input->getArgument('type');
     $output->writeln("<info>benchmark {$type}:</info>\t<comment>{$times} times</comment>");
     switch ($type) {
         case 'all':
             foreach ($config->getQueries() as $name => $query) {
                 $this->benchmark($output, $query, $name, $times);
             }
             break;
         case 'file':
             foreach ($config->getQueries() as $name => $query) {
                 if (FileQuery::is_a($query)) {
                     $this->benchmark($output, $query, $name, $times);
                 }
             }
             break;
         case 'database':
             foreach ($config->getQueries() as $name => $query) {
                 if (DatabaseQuery::is_a($query)) {
                     $this->benchmark($output, $query, $name, $times);
                 }
             }
             break;
         default:
             $output->writeln("<error>Unknown type \"{$type}\".</error>");
             break;
     }
 }
示例#2
0
 /**
  * dump ip database
  *
  * @param string $type division or division_id
  *
  * @throws \Exception
  */
 public function run($type = 'default')
 {
     $this->stdout("dump {$type}:\n", Console::FG_GREEN);
     switch ($type) {
         case 'default':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 $this->dumpDefault($query, $name);
             }
             break;
         case 'division':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 $this->dumpDivision($query, $name);
             }
             break;
         case 'division_id':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 if (FileQuery::is_a($query)) {
                     $this->dumpDivisionWithId($query, $name);
                 }
             }
             break;
         default:
             $this->stderr("Unknown type \"{$type}\".\n", Console::FG_GREY, Console::BG_RED);
             break;
     }
 }
示例#3
0
 /**
  * benchmark
  *
  * @param string $type file or database
  *
  * @throws \Exception
  */
 public function run($type = 'all')
 {
     $times = $this->controller->times;
     if ($times < 1) {
         $this->stderr("benchmark {$times} is too small\n", Console::FG_GREY, Console::BG_RED);
         return;
     }
     $this->stdout("benchmark {$type}:", Console::FG_GREEN);
     $this->stdout("\t{$times} times\n", Console::FG_YELLOW);
     switch ($type) {
         case 'all':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 $this->benchmark($query, $name, $times);
             }
             break;
         case 'file':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 if (FileQuery::is_a($query)) {
                     $this->benchmark($query, $name, $times);
                 }
             }
             break;
         case 'database':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 if (DatabaseQuery::is_a($query)) {
                     $this->benchmark($query, $name, $times);
                 }
             }
             break;
         default:
             $this->stderr("Unknown type \"{$type}\".\n", Console::FG_GREY, Console::BG_RED);
             break;
     }
 }
示例#4
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  * @throws \Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = Config::getInstance();
     $noProgress = $input->getOption('no-progress');
     $type = $input->getArgument('type');
     $output->writeln("<info>dump {$type}:</info>");
     switch ($type) {
         case 'default':
             foreach ($config->getQueries() as $name => $query) {
                 $this->dumpDefault($output, $query, $name, $noProgress);
             }
             break;
         case 'division':
             foreach ($config->getQueries() as $name => $query) {
                 $this->dumpDivision($output, $query, $name, $noProgress);
             }
             break;
         case 'division_id':
             foreach ($config->getQueries() as $name => $query) {
                 if (FileQuery::is_a($query)) {
                     $this->dumpDivisionWithId($output, $query, $name, $noProgress);
                 }
             }
             break;
         case 'count':
             foreach ($config->getQueries() as $name => $query) {
                 $this->dumpCount($output, $query, $name, $noProgress);
             }
             break;
         default:
             $output->writeln("<error>Unknown type \"{$type}\".</error>");
             break;
     }
 }
示例#5
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  * @throws \Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = Config::getInstance();
     $cleanDivision = false;
     $type = $input->getArgument('type');
     $output->writeln("<info>clean {$type}:</info>");
     switch ($type) {
         case 'all':
             foreach ($config->getQueries() as $name => $query) {
                 if (DatabaseQuery::is_a($query)) {
                     $cleanDivision = true;
                 }
                 $this->clean($output, $query, $name);
             }
             break;
         case 'file':
             foreach ($config->getQueries() as $name => $query) {
                 if (FileQuery::is_a($query)) {
                     $this->clean($output, $query, $name);
                 }
             }
             break;
         case 'database':
             foreach ($config->getQueries() as $name => $query) {
                 if (DatabaseQuery::is_a($query)) {
                     $cleanDivision = true;
                     $this->clean($output, $query, $name);
                 }
             }
             break;
         default:
             $output->writeln("<error>Unknown type \"{$type}\".</error>");
             break;
     }
     if ($cleanDivision) {
         $this->cleanDivision($output);
     }
 }
示例#6
0
 /**
  * benchmark
  *
  * @param string $type file or database
  *
  * @throws \Exception
  */
 public function run($type = 'all')
 {
     $cleanDivision = false;
     $this->stdout("clean {$type}:\n", Console::FG_GREEN);
     switch ($type) {
         case 'all':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 if (DatabaseQuery::is_a($query)) {
                     $cleanDivision = true;
                 }
                 $this->clean($query, $name);
             }
             break;
         case 'file':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 if (FileQuery::is_a($query)) {
                     $this->clean($query, $name);
                 }
             }
             break;
         case 'database':
             foreach ($this->ipv4->getQueries() as $name => $query) {
                 if (DatabaseQuery::is_a($query)) {
                     $cleanDivision = true;
                     $this->clean($query, $name);
                 }
             }
             break;
         default:
             $this->stderr("Unknown type \"{$type}\".", Console::FG_GREY, Console::BG_RED);
             break;
     }
     if ($cleanDivision) {
         $this->cleanDivision();
     }
 }