Beispiel #1
0
 public function testThe()
 {
     $ps = new Reader();
     $time = TimeMachine::getInstance();
     $time->mock(new Mock(new Storage('serialized-file:///' . __DIR__ . '/mocks/time.serialized')));
     $ps->mock(new Mock(new Storage('serialized-file:///' . __DIR__ . '/mocks/ps-reader.serialized')));
     $history = new History();
     $now = $time->microNow();
     do {
         $processStates = $ps->get();
         $history->add($processStates);
         echo '.';
         sleep(1);
     } while ($time->microNow() < $now + 5);
     print_r($history->processes);
 }
Beispiel #2
0
 public function execute()
 {
     set_time_limit(0);
     $this->history = new History();
     $this->history->minCpuPercent = $this->minCpuPercent;
     $this->history->minMemPercent = $this->minMemPercent;
     $reader = new Reader();
     $time = TimeMachine::getInstance();
     $start = $time->microNow();
     $lastUpdate = $start;
     do {
         $processStates = $reader->get();
         $this->history->add($processStates);
         echo '.';
         $now = $time->microNow();
         if ($lastUpdate < $now - $this->saveInterval) {
             $lastUpdate = $now;
             echo 's';
             $this->renderReport();
         }
         sleep($this->delay);
     } while ($this->timeLimit === null || $now > $start + $this->timeLimit);
 }