enb
Version:
Faster BEM/BEViS assembler
67 lines (56 loc) • 1.84 kB
JavaScript
var _ = require('lodash');
var prettyMs = require('pretty-ms');
var Table = require('cli-table');
/**
* Convert milliseconds to a human readable string.
*
* @param {Number} value
*
* @returns {String}
*/
function convertMs(value) {
return Number.isFinite(value) ? prettyMs(value) : String(value);
}
module.exports = {
printTechTable: function (data) {
var printTable = new Table({
head: ['Tech', 'Number of calls', 'Time spend (%)', 'Build Time']
});
_.map(data, function (techInfo) {
printTable.push([
techInfo.tech,
techInfo.callNumber,
techInfo.buildTimePercent.toFixed(3),
convertMs(techInfo.buildTime)
]);
});
console.log(printTable.toString());
},
printTargetTable: function (data) {
var printTable = new Table({
head: ['Target', 'Self time', 'Wating time', 'Total time']
});
_.map(data, function (targetInfo) {
printTable.push([
targetInfo.target,
convertMs(targetInfo.selfTime),
convertMs(targetInfo.watingTime),
convertMs(targetInfo.totalTime)
]);
});
console.log(printTable.toString());
},
printTechPercentileTable: function (techPercentiles, percentileRanks) {
var printTable = new Table({
head: ['Tech'].concat(percentileRanks.map(function (rank) {
return rank + 'th';
}))
});
techPercentiles.map(function (techInfo) {
printTable.push([techInfo.tech].concat(techInfo.percentiles.map(function (item) {
return convertMs(item.value);
})));
});
console.log(printTable.toString());
},
};