Commit f65fde8b by Torkel Ödegaard

Merge pull request #3148 from utkarshcmu/units

Added throughput units.
parents 0a04b135 b5f18561
...@@ -310,6 +310,16 @@ function($, _) { ...@@ -310,6 +310,16 @@ function($, _) {
}; };
}; };
kbn.formatBuilders.simpleCountUnit = function(symbol) {
var units = ['', 'K', 'M', 'B', 'T'];
var scaler = kbn.formatBuilders.scaledUnits(1000, units);
return function(size, decimals, scaledDecimals) {
if (size === null) { return ""; }
var scaled = scaler(size, decimals, scaledDecimals);
return scaled + " " + symbol;
};
};
///// VALUE FORMATS ///// ///// VALUE FORMATS /////
// Dimensionless Units // Dimensionless Units
...@@ -344,6 +354,12 @@ function($, _) { ...@@ -344,6 +354,12 @@ function($, _) {
kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps'); kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps');
kbn.valueFormats.Bps = kbn.formatBuilders.decimalSIPrefix('Bps'); kbn.valueFormats.Bps = kbn.formatBuilders.decimalSIPrefix('Bps');
// Throughput
kbn.valueFormats.ops = kbn.formatBuilders.simpleCountUnit('ops');
kbn.valueFormats.rps = kbn.formatBuilders.simpleCountUnit('rps');
kbn.valueFormats.wps = kbn.formatBuilders.simpleCountUnit('wps');
kbn.valueFormats.iops = kbn.formatBuilders.simpleCountUnit('iops');
// Energy // Energy
kbn.valueFormats.watt = kbn.formatBuilders.decimalSIPrefix('W'); kbn.valueFormats.watt = kbn.formatBuilders.decimalSIPrefix('W');
kbn.valueFormats.kwatt = kbn.formatBuilders.decimalSIPrefix('W', 1); kbn.valueFormats.kwatt = kbn.formatBuilders.decimalSIPrefix('W', 1);
...@@ -523,6 +539,15 @@ function($, _) { ...@@ -523,6 +539,15 @@ function($, _) {
] ]
}, },
{ {
text: 'throughput',
submenu: [
{text: 'ops/sec (ops)', value: 'ops' },
{text: 'reads/sec (rps)', value: 'rps' },
{text: 'writes/sec (wps)', value: 'wps' },
{text: 'I/O ops/sec (iops)', value: 'iops'},
]
},
{
text: 'length', text: 'length',
submenu: [ submenu: [
{text: 'millimetre (mm)', value: 'lengthmm'}, {text: 'millimetre (mm)', value: 'lengthmm'},
...@@ -576,7 +601,7 @@ function($, _) { ...@@ -576,7 +601,7 @@ function($, _) {
{text: 'Inches of mercury', value: 'pressurehg' }, {text: 'Inches of mercury', value: 'pressurehg' },
{text: 'PSI', value: 'pressurepsi' }, {text: 'PSI', value: 'pressurepsi' },
] ]
}, }
]; ];
}; };
......
...@@ -62,6 +62,12 @@ define([ ...@@ -62,6 +62,12 @@ define([
describeValueFormat('ns', 25, 1, 0, '25 ns'); describeValueFormat('ns', 25, 1, 0, '25 ns');
describeValueFormat('ns', 2558, 50, 0, '2.56 µs'); describeValueFormat('ns', 2558, 50, 0, '2.56 µs');
describeValueFormat('ops', 123, 1, 0, '123 ops');
describeValueFormat('rps', 456000, 1000, -1, '456K rps');
describeValueFormat('rps', 123456789, 1000000, 2, '123.457M rps');
describeValueFormat('wps', 789000000, 1000000, -1, '789M wps');
describeValueFormat('iops', 11000000000, 1000000000, -1, '11B iops');
describe('kbn.toFixed and negative decimals', function() { describe('kbn.toFixed and negative decimals', function() {
it('should treat as zero decimals', function() { it('should treat as zero decimals', function() {
var str = kbn.toFixed(186.123, -2); var str = kbn.toFixed(186.123, -2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment