Skip to content

Commit

Permalink
Benchmark runner: optional location tracking.
Browse files Browse the repository at this point in the history
Based on the work from ZHANG Bei <ikarienator@gmail.com>.

https://code.google.com/p/esprima/issues/detail?id=412
  • Loading branch information
ariya committed Apr 5, 2013
1 parent 2555248 commit 355bab9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ if (typeof window !== 'undefined') {
var Benchmark,
esprima,
dirname,
option,
quick,
loc = false,
fs,
readFileSync,
log;
Expand All @@ -287,7 +288,8 @@ if (typeof window !== 'undefined') {
Benchmark = require('./3rdparty/benchmark');
esprima = require('../esprima');
fs = require('fs');
option = process.argv[2];
quick = process.argv[2] === 'quick' || process.argv[3] === 'quick';
loc = process.argv[2] === 'loc' || process.argv[3] === 'loc';
readFileSync = function readFileSync(filename) {
return fs.readFileSync(filename, 'utf-8');
};
Expand All @@ -306,7 +308,7 @@ if (typeof window !== 'undefined') {
size = source.length;
totalSize += size;
return suite.add(filename, function () {
var syntax = esprima.parse(source);
var syntax = esprima.parse(source, {loc: loc});
tree.push(syntax.body.length);
}, {
'onComplete': function (event, bench) {
Expand All @@ -323,7 +325,7 @@ if (typeof window !== 'undefined') {
}).run();
}

if (option === 'quick') {
if (quick) {
runTests(quickFixture);
} else {
runTests(fullFixture);
Expand Down

0 comments on commit 355bab9

Please sign in to comment.