Example #1
0
 protected function setup()
 {
     $this->lineElement;
     $this->lineElementRef = new HatenaSyntax_LineElement($this->bracket, $this->footnote, $this->inlineTag);
     $this->block;
     $this->blockRef = PEG::memo(new HatenaSyntax_Block($this));
 }
Example #2
0
 protected function setUp()
 {
     $this->lineElement;
     $this->lineElementRef = new OrgModeSyntax_LineElement($this->bracket, $this->inlineTag);
     $this->block;
     $this->blockRef = PEG::memo(new OrgModeSyntax_Block($this));
 }
Example #3
0
 */
$t = new Benchmark_Timer();
$str = '((((((((1))))))))';
$t->start();
// メモ化していないパーサ
$a = PEG::ref($a_ref);
$p = PEG::ref($p_ref);
$a_ref = PEG::choice(PEG::seq($p, '+', $a), PEG::seq($p, '-', $a), $p);
$p_ref = PEG::choice(PEG::seq('(', $a, ')'), '1');
$a->parse(PEG::context($str));
$t->setMarker('no memoize');
// メモ化しているパーサ
$a = PEG::ref($a_ref);
$p = PEG::ref($p_ref);
$a_ref = PEG::memo(PEG::choice(PEG::seq($p, '+', $a), PEG::seq($p, '-', $a), $p));
$p_ref = PEG::memo(PEG::choice(PEG::seq('(', $a, ')'), '1'));
$a->parse($c = PEG::context($str));
$t->setMarker('memoize');
$t->stop();
$t->display();
/* 結果
---------------------------------------------------------
marker       time index            ex time         perct   
---------------------------------------------------------
Start        1242400475.10093900   -                0.00%
---------------------------------------------------------
no memoize   1242400476.30805000   1.207111        99.74%
---------------------------------------------------------
memoize      1242400476.31115500   0.003105         0.26%
---------------------------------------------------------
Stop         1242400476.31117700   0.000022         0.00%