var ParserJison = require('../src/parser'),
    GrammarPegjs = require('../src/grammar.pegjs.js')

var AST   = require('../src/ast'),
    types = require('../src/types'),
    fs    = require('fs'),
    Benchmark = require('benchmark')

var parserJison = new ParserJison()

function parsePegjs (code) {
  return GrammarPegjs.parse(code, {file: '(unknown)'})
}
function parseJison (code) {
  return parserJison.parse(code)
}

var exampleCode = fs.readFileSync(__dirname+'/../examples/fibonacci.hb', 'utf8')

var suite = new Benchmark.Suite()

suite
var jisonBenchmark = new Benchmark('Jison', function () {
  parseJison(exampleCode)
})
var pegjsBenchmark = new Benchmark('PEG.js', function () {
  parsePegjs(exampleCode)
})

;[jisonBenchmark, pegjsBenchmark].forEach(function (benchmark) {
  benchmark.options.minSamples = 100
  var result = benchmark.run()
  console.log(result.toString())
})

@@ -102,16 +102,22 @@
 r AST   
+      
 = requir
@@ -143,16 +143,22 @@
   types 
+      
 = requir
@@ -180,18 +180,78 @@
 '),%0A    
-fs
+reportError = require('../src/util').reportError,%0A    fs      
     = re
@@ -277,16 +277,18 @@
 nchmark 
+  
 = requir
@@ -553,17 +553,13 @@
 les/
-fibonacci
+all-2
 .hb'
@@ -572,49 +572,95 @@
 8')%0A
-%0Avar suite = new Benchmark.Suite()%0A%0Asuite
+try %7B%0A  parseJison(exampleCode)%0A%7D catch (err) %7B%0A  reportError(err)%0A  process.exit(0)%0A%7D%0A
 %0Avar

Tweak parser benchmarking script