From ff0e31e4c47ec109ce97c4a99feec4c602f4470e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 27 Jan 2011 09:38:35 -0500 Subject: [PATCH] add benchmark command --- bin/messc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/messc b/bin/messc index df4eb31..70f5a33 100755 --- a/bin/messc +++ b/bin/messc @@ -24,21 +24,29 @@ args = args.filter(function (arg) { case 'version': sys.puts("messc " + mess.version.join('.') + " (MESS Compiler) [JavaScript]"); process.exit(0); + break; case 'verbose': options.verbose = true; break; case 'd': + case 'debug': options.debug = true; + break; case 's': case 'silent': options.silent = true; break; + case 'b': + case 'benchmark': + options.benchmark = true; + break; case 'h': case 'help': sys.puts("Usage: messc source"); sys.puts("Options:"); sys.puts(" -j\tParse JSON map manifest"); process.exit(0); + break; } }); @@ -62,6 +70,10 @@ fs.readFile(input, 'utf-8', function (e, data) { process.exit(1); } + if (options.benchmark) { + var start = +new Date; + } + new mess.Renderer({ filename: input, local_data_dir: path.dirname(input), @@ -70,7 +82,12 @@ fs.readFile(input, 'utf-8', function (e, data) { mess.writeError(err, options); process.exit(1); } else { - sys.puts(output); + if (!options.benchmark) { + sys.puts(output); + } else { + var duration = (+new Date) - start; + console.log('Benchmark: ' + (duration / 1000) + 'ms'); + } } }); });