From ac4f3685b69421d4ff5281aede911a8c43507af4 Mon Sep 17 00:00:00 2001 From: Patrick Stadler Date: Thu, 13 Mar 2014 15:46:57 +0100 Subject: [PATCH] execution times are now displayed in a pretty format --- lib/flight.js | 3 +-- lib/flightplan.js | 10 +++++----- lib/remote.js | 8 +++----- package.json | 3 ++- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/flight.js b/lib/flight.js index 997dbfc..4937d2b 100644 --- a/lib/flight.js +++ b/lib/flight.js @@ -51,8 +51,7 @@ Flight.prototype = { } transport.close(); - t = process.hrtime(t); - this.status.executionTime = Math.round(t[0]*1e3 + t[1]/1e6); + this.status.executionTime = process.hrtime(t); return future.return(); }.bind(this)).run(); diff --git a/lib/flightplan.js b/lib/flightplan.js index 2083192..06c4038 100644 --- a/lib/flightplan.js +++ b/lib/flightplan.js @@ -1,4 +1,5 @@ var Fiber = require('fibers') + , prettyTime = require('pretty-hrtime') , Logger = require('./logger') , Briefing = require('./briefing') , LocalFlight = require('./local') @@ -291,7 +292,7 @@ Flightplan.prototype = { var status = flight.getStatus() , flightNumber = this.logger.format('%s/%s', i+1, len).magenta - , executionTime = this.logger.format('%s%s', status.executionTime, 'ms').magenta + , executionTime = prettyTime(status.executionTime).magenta , crashReason = !status.crashRecordings ? '' : this.logger.format('when %s', status.crashRecordings); if(flight.isAborted()) { @@ -303,18 +304,17 @@ Flightplan.prototype = { this.logger.space(); } - t = process.hrtime(t); - this.status.executionTime = Math.round(t[0]*1e3 + t[1]/1e6); + this.status.executionTime = process.hrtime(t); if(this.isAborted()) { this.logger.error('Flightplan aborted after'.error - , this.logger.format('%s%s', this.status.executionTime, 'ms').magenta); + , prettyTime(this.status.executionTime).magenta); this.disasterCallback(); this.debriefingCallback(); process.exit(1); } else { this.logger.success('Flightplan finished after'.success - , this.logger.format('%s%s', this.status.executionTime, 'ms').magenta); + , prettyTime(this.status.executionTime).magenta); this.successCallback(); this.debriefingCallback(); process.exit(0); diff --git a/lib/remote.js b/lib/remote.js index f9d01c8..75d974b 100644 --- a/lib/remote.js +++ b/lib/remote.js @@ -32,11 +32,9 @@ RemoteFlight.prototype.__start = function() { } transport.close(); - t = process.hrtime(t); - flight.status.executionTime = Math.round(t[0]*1e3 + t[1]/1e6); - if(flight.status.executionTime > this.status.executionTime) { - this.status.executionTime = flight.status.executionTime; - } + flight.status.executionTime = process.hrtime(t); + this.status.executionTime = flight.status.executionTime; + return future.return(); }.bind(this)).run(); diff --git a/package.json b/package.json index a4d8030..9a1dec0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "ssh2": "~0.2.17", "colors": "~0.6.2", "commander": "~2.1.0", - "prompt": "~0.2.12" + "prompt": "~0.2.12", + "pretty-hrtime": "^0.2.1" }, "devDependencies": { "gulp": "~3.5.2",