From 7d37b1503752a7e896ea795a20b8a6f5fe8590b7 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Tue, 2 Feb 2016 04:15:46 +0800 Subject: [PATCH] add progress bar --- benchmark.js | 10 +++++++--- package.json | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/benchmark.js b/benchmark.js index 4fe89ab..7e0999c 100644 --- a/benchmark.js +++ b/benchmark.js @@ -11,7 +11,7 @@ var fs = require('fs'), querystring = require('querystring'), chalk = require('chalk'), Table = require('cli-table'), - + Progress = require('progress'), Minimize = require('minimize'), minimize = new Minimize(); @@ -29,6 +29,11 @@ var fileNames = [ 'wikipedia' ].sort(); +var progress = new Progress('[:bar] :etas :fileName', { + width: 50, + total: fileNames.length +}); + var table = new Table({ head: ['File', 'Before', 'After', 'Minimize', 'Will Peavy', 'htmlcompressor.com', 'Savings', 'Time'], colWidths: [20, 25, 25, 25, 25, 25, 20, 10] @@ -79,8 +84,6 @@ function run(tasks, done) { var rows = {}; run(fileNames.map(function (fileName) { return function (done) { - console.log('Processing...', fileName); - var filePath = path.join('benchmarks/', fileName + '.html'); var original = { filePath: filePath, @@ -271,6 +274,7 @@ run(fileNames.map(function (fileName) { [blueTime(minifiedTime), blueTime(gzMinifiedTime)].join('\n') ); rows[fileName] = row; + progress.tick({ fileName: fileName }); done(); }); }; diff --git a/package.json b/package.json index c08f7f7..382b575 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "grunt-jscs": "2.7.x", "load-grunt-tasks": "3.4.x", "minimize": "1.8.x", + "progress": "1.1.x", "qunit": "0.7.x", "time-grunt": "1.3.x" }, -- 2.34.1