コード例 #1
0
 public function test_construct_and_index()
 {
     $filename = 'data/big_granito_1.html';
     $tmr = self::timer();
     $mmr = self::memer();
     $html = self::file_get_contents($filename);
     $mem = self::memer($mmr);
     $exe = self::timer($tmr);
     self::log("Loaded    " . self::fmtNumber(strlen($html) / 1024, 2) . "Kb\tin\t{$exe}\t{$mem} RAM");
     $tmr = self::timer();
     $mmr = self::memer();
     $doc = new hQuery($html, false);
     $mem = self::memer($mmr);
     $exe = self::timer($tmr);
     self::log("Construct " . self::fmtNumber($doc->size / 1024, 2) . "Kb\tin\t{$exe}\t{$mem} RAM");
     $doc->location(self::fn($filename));
     $tmr = self::timer();
     $mmr = self::memer();
     $tags = $doc->index();
     $mem = self::memer($mmr);
     $exe = self::timer($tmr);
     $this->assertLessThan(6000000, self::timer($tmr, false), 'should index 3Mb in less then 3 sec');
     $count = self::fmtNumber(self::listSumCounts($tags));
     self::log("Indexed   {$count} tags\tin\t{$exe}\t{$mem} RAM");
     self::log("Original Charset: {$doc->charset}");
     $tags = array_map('count', $tags);
     $counts = NULL;
     foreach ($tags as $k => $v) {
         $counts[$v] = (empty($counts[$v]) ? '' : $counts[$v] . ', ') . $k;
     }
     krsort($counts);
     // self::log('Tag counts:', $counts);
     return array($doc);
 }