Skip to content

Commit

Permalink
Try a different table layout
Browse files Browse the repository at this point in the history
```
10 connections

Stat    2.5%  50%   97.5%  99%    Avg      Stdev   Max
Latency 17 ms 29 ms 204 ms 334 ms 45.32 ms 64.1 ms 954.08 ms

Stat      1%     2.5%   50%     97.5%  Avg     Stdev  Min
Req/Sec   91     91     274     288    217.67  89.75  91
Bytes/Sec 688 kB 688 kB 2.03 MB 2.1 MB 1.58 MB 642 kB 657 kB

Req/Bytes counts sampled once per second.

653 requests in 3s, 4.71 MB read
```
  • Loading branch information
goto-bus-stop committed Jul 20, 2018
1 parent 56377f2 commit 50e2fbb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
47 changes: 39 additions & 8 deletions lib/progressTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,25 @@ function track (instance, opts) {
// if the user doesn't want to render the table, we can just return early
if (!opts.renderResultsTable) return

logToStream(table([
asColor(chalk.cyan, ['Stat', '2.5%', '50%', '97.5%', '99%', 'Avg', 'Stdev', 'Max']),
asRow(chalk.bold('Latency (ms)'), result.latency),
asRow(chalk.bold('Req/Sec'), result.requests),
asRow(chalk.bold('Bytes/Sec'), asBytes(result.throughput))
], {
const tableOpts = {
border: getBorderCharacters('void'),
columnDefault: {
paddingLeft: 0,
paddingRight: 1
},
drawHorizontalLine: () => false
}))
}

logToStream(table([
asColor(chalk.cyan, ['Stat', '2.5%', '50%', '97.5%', '99%', 'Avg', 'Stdev', 'Max']),
asLowRow(chalk.bold('Latency'), asMs(result.latency))
], tableOpts))
logToStream(table([
asColor(chalk.cyan, ['Stat', '1%', '2.5%', '50%', '97.5%', 'Avg', 'Stdev', 'Min']),
asHighRow(chalk.bold('Req/Sec'), result.requests),
asHighRow(chalk.bold('Bytes/Sec'), asBytes(result.throughput))
], tableOpts))
logToStream('Req/Bytes counts sampled once per second.\n')

if (opts.renderLatencyTable) {
const latency = table([
Expand Down Expand Up @@ -158,7 +164,8 @@ function trackAmount (instance, opts, iOpts) {
return progressBar
}

function asRow (name, stat) {
// create a table row for stats where low values is better
function asLowRow (name, stat) {
return [
name,
stat.p2_5,
Expand All @@ -171,10 +178,34 @@ function asRow (name, stat) {
]
}

// create a table row for stats where high values is better
function asHighRow (name, stat) {
return [
name,
stat.p1,
stat.p2_5,
stat.p50,
stat.p97_5,
stat.average,
stat.stddev,
typeof stat.min === 'string' ? stat.min : Math.floor(stat.min * 100) / 100
]
}

function asColor (colorise, row) {
return row.map((entry) => colorise(entry))
}

function asMs (stat) {
const result = Object.create(null)
Object.keys(stat).forEach((k) => {
result[k] = `${stat[k]} ms`
})
result.max = typeof stat.max === 'string' ? stat.max : `${Math.floor(stat.max * 100) / 100} ms`

return result
}

function asBytes (stat) {
const result = Object.create(stat)

Expand Down
6 changes: 5 additions & 1 deletion test/cli-ipc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ const lines = [
/10 connections.*$/,
/$/,
/Stat.*2\.5%.*50%.*97\.5%.*99%.*Avg.*Stdev.*Max.*$/,
/Latency \(ms\).*$/,
/Latency.*$/,
/$/,
/Stat.*1%.*2\.5%.*50%.*97\.5%.*Avg.*Stdev.*Min.*$/,
/Req\/Sec.*$/,
/Bytes\/Sec.*$/,
/$/,
/Req\/Bytes counts sampled once per second.*$/,
/$/,
/.* requests in \d+s, .* read/
]

Expand Down
6 changes: 5 additions & 1 deletion test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ const lines = [
/10 connections.*$/,
/$/,
/Stat.*2\.5%.*50%.*97\.5%.*99%.*Avg.*Stdev.*Max.*$/,
/Latency \(ms\).*$/,
/Latency.*$/,
/$/,
/Stat.*1%.*2\.5%.*50%.*97\.5%.*Avg.*Stdev.*Min.*$/,
/Req\/Sec.*$/,
/Bytes\/Sec.*$/,
/$/,
/Req\/Bytes counts sampled once per second.*$/,
/$/,
/.* requests in \d+s, .* read/
]

Expand Down
8 changes: 6 additions & 2 deletions test/envPort.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ const lines = [
/Running 1s test @ .*$/,
/10 connections.*$/,
/$/,
/Stat.*Avg.*Stdev.*Max.*$/,
/Latency \(ms\).*$/,
/Stat.*2\.5%.*50%.*97\.5%.*99%.*Avg.*Stdev.*Max.*$/,
/Latency.*$/,
/$/,
/Stat.*1%.*2\.5%.*50%.*97\.5%.*Avg.*Stdev.*Min.*$/,
/Req\/Sec.*$/,
/Bytes\/Sec.*$/,
/$/,
/Req\/Bytes counts sampled once per second.*$/,
/$/,
/.* requests in \d+s, .* read/
]

Expand Down

0 comments on commit 50e2fbb

Please sign in to comment.