Exemple #1
0
 /**
  * @covers BT\Timer::reset
  */
 public function testReset()
 {
     $this->object->start();
     $this->object->stop();
     $this->assertInternalType("float", $this->object->getStart());
     $this->assertInternalType("float", $this->object->getStop());
     $this->object->reset();
     $this->assertInternalType("float", $this->object->getStart());
     $this->assertInternalType("float", $this->object->getStop());
 }
Exemple #2
0
 public function test_average_calculations()
 {
     $timer = new Timer();
     // This should false if the timer has not been started
     $this->assertFalse($timer->average());
     $timer->start();
     $timer->stop();
     $timer->reset();
     // Should also return false if reset
     $this->assertFalse($timer->average());
     // Set some known values
     $timer->start();
     $timer->stop();
     $timer->stop_time = $timer->start_time + 100;
     $timer->set_total_items(100);
     $timer->current_item = 4;
     $this->assertEquals(25, $timer->average());
 }
	}
	mysql_free_result($thread_result);
	if($changed)
	$cindex->commit();
	
	//Do the upload:
	$term = new Zend_Search_Lucene_Index_Term($fileid, 'fileid');
	$docIds = $uindex->termDocs($term);
	if(count($docIds) == 0)
	{
		$doc = new Zend_Search_Lucene_Document();
		$doc->addField(Zend_Search_Lucene_Field::Keyword('fileid', $fileid));
		$doc->addField(Zend_Search_Lucene_Field::Unstored('filename', $filename));
		$doc->addField(Zend_Search_Lucene_Field::Unstored('uploader', $uploader));
		$uindex->addDocument($doc);
		$uindex->commit();
	}
	echo "\n";
	flush();
}

echo "Done.\noptimizing indices... ";
flush();

$cindex->optimize();
$uindex->optimize();

echo "Done (".number_format($timer->reset(), 5)."s)\n\nUpload index size is ".$uindex->count().", ".$uindex->numDocs()." documents.\n\nComment index size is ".$cindex->count().", ".$cindex->numDocs()." documents.\n\n";


?>
// Make Lex object
$Lex = $Tree->make_lex();
$Lex->dump();
echo "----------\n";
// Make Grammar object
$rawgrammar = $Tree->evaluate();
$Grammar = GrammarBuilder::make($rawgrammar);
// Load special rules
$Grammar->exclude_terminal(J_EXPR_STATEMENT, '{');
$Grammar->exclude_terminal(J_EXPR_STATEMENT, J_FUNCTION);
// trash dummy rules that we used just to get redundant terminals into the Lex
$Grammar->remove_rules(J_RESERVED);
$Grammar->remove_rules(J_IGNORE);
$Grammar->dump($Lex);
echo "----------\n";
printf("Ready to build automaton after %f milliseconds\n", $Timer->reset());
// Make Parse Table object
$NDA = new LRNDA($Grammar, 1);
printf("NDA built in %f milliseconds\n", $Timer->reset());
$Table = $NDA->export();
printf("Table exported in %f milliseconds\n", $Timer->reset());
/**
 * Dump classes into files
 */
@ob_end_flush();
ob_start();
$Lex->class_export($lexname, $commentData);
file_put_contents($classdir . '/' . $lexname . '.php', "<?php\n" . ob_get_contents());
ob_clean();
$Grammar->class_export($grammarname, $commentData);
file_put_contents($classdir . '/' . $grammarname . '.php', "<?php\n" . ob_get_contents());