aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-10 17:51:38 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-10 17:51:38 -0800
commitcb553e8003aa748e20f7c3aeb93a75e5bbeeb23c (patch)
treec2dce63d1d2e06fda8e9f554382bc0f51e8e0870 /js
parent586d343d74de008d2ce62e15a5d153be173fd791 (diff)
Added --time option to js/bin/commonmark.
Diffstat (limited to 'js')
-rwxr-xr-xjs/bin/commonmark14
1 files changed, 13 insertions, 1 deletions
diff --git a/js/bin/commonmark b/js/bin/commonmark
index e48e05e..6c9955c 100755
--- a/js/bin/commonmark
+++ b/js/bin/commonmark
@@ -9,12 +9,15 @@ var file;
var files = [];
var options = { sourcepos: false };
var format = 'html';
+var time = false;
var i;
for (i = 2; i < process.argv.length; i++) {
var arg = process.argv[i];
if (arg === '--ast') {
format = 'ast';
+ } else if (arg === '--time') {
+ time = true;
} else if (arg === '--sourcepos') {
options.sourcepos = true;
} else if (/^--/.test(arg)) {
@@ -44,4 +47,13 @@ for (i = 0; i < files.length; i++) {
inps.push(fs.readFileSync(file, 'utf8'));
}
-process.stdout.write(renderer.render(parser.parse(inps.join('\n'))));
+var inp = inps.join('\n');
+if (time) { console.time("parsing"); }
+var doc = parser.parse(inp);
+if (time) { console.timeEnd("parsing"); }
+
+if (time) { console.time("rendering"); }
+var rendered = renderer.render(doc);
+if (time) { console.timeEnd("rendering"); }
+
+if (!time) { process.stdout.write(rendered); } \ No newline at end of file