Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autocannon-reporter

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autocannon-reporter - npm Package Compare versions

Comparing version 0.0.6 to 1.0.0

4

package.json
{
"name": "autocannon-reporter",
"version": "0.0.6",
"version": "1.0.0",
"description": "A tool for creating html reports for autocannon",

@@ -13,3 +13,3 @@ "main": "index.js",

"scripts": {
"test": "lab --ignore Document,Node,Element,Comment,Text,document",
"test": "lab -l --ignore Document,Node,Element,Comment,Text,document",
"lint": "standard"

@@ -16,0 +16,0 @@ },

@@ -5,7 +5,7 @@ 'use strict'

const prettyBytes = require('pretty-bytes')
const moment = require('moment')
const fs = require('fs')
const path = require('path')
const moment = require('moment')
function datestuff (date) {
return moment(date).format('MMMM Do YYYY, h:mm:ss a')
return moment(date).format('DD-MMM-YYYY, HH:mm:ss')
}

@@ -19,3 +19,3 @@

function reportBody (results, hx, compare) {
function reportBody (results, hx, compare = []) {
return hx`

@@ -28,20 +28,45 @@ <div>

<div class='report'>
<div class ='object content no-border spaceout'>
<ul class ='grid'>
<li><b>Start Time:</b> ${datestuff(results.start)} </li>
<li><b>Connections:</b> ${results.connections}</li>
<li><b>Timeouts:</b> ${results.timeouts}</li>
<li><b>Throughput average:</b> ${prettyBytes(results.throughput.average)}/sec</li>
</ul>
<ul class ='grid'>
<li><b>Finish Time:</b> ${datestuff(results.finish)}</li>
<li><b>Pipelining:</b> ${results.pipelining}</li>
<li><b>Requests Average:</b> ${results.requests.average} reqs/sec</li>
</ul>
<ul class='grid'>
<li><b>Duration:</b> ${results.duration + ' sec(s)'}</li>
<li><b>Errors:</b> ${results.errors}</li>
<li><b>Latency average:</b> ${results.latency.average} ms</li>
</ul>
</div>
<table>
<tr>
<th>Start time</th>
<th>Finish time</th>
<th>Duration</th>
<th>Connections</th>
<th>Pipelining</th>
<th>Errors</th>
<th>Timeouts</th>
<th>Requests avg.</th>
<th>Latency avr.</th>
<th>Throughput avg.</th>
</tr>
<tr>
<td>${datestuff(results.start)}</td>
<td>${datestuff(results.finish)}</td>
<td>${results.duration + ' sec(s)'}</td>
<td>${results.connections}</td>
<td>${results.pipelining}</td>
<td>${results.errors}</td>
<td>${results.timeouts}</td>
<td>${results.requests.average} reqs/sec</td>
<td>${results.latency.average} ms</td>
<td>${prettyBytes(results.throughput.average)}/sec</td>
</tr>
${[...compare].reverse().map(function (value) {
return hx`
<tr>
<td>${datestuff(value.start)}</td>
<td>${datestuff(value.finish)}</td>
<td>${value.duration + ' sec(s)'}</td>
<td>${value.connections}</td>
<td>${value.pipelining}</td>
<td>${value.errors}</td>
<td>${value.timeouts}</td>
<td>${value.requests.average} reqs/sec</td>
<td>${value.latency.average} ms</td>
<td>${prettyBytes(value.throughput.average)}/sec</td>
</tr>
`
})}
</table>
${results['2xx'] + results.non2xx > 0 ? panels(results, hx, compare) : warnPanel(results, hx)}

@@ -86,3 +111,3 @@ ${compare && compare.length > 0 ? comparePanels(results, hx, compare) : ''}

<h2 class='symbol'>-</h2>
<h2>Response Types Piechart</h2>
<h2>Response Types Piechart (Overall)</h2>
</div>

@@ -165,3 +190,2 @@ <div class='content graph'>

${requestsPanel(results, hx)}
${bandwidthPanel(results, hx)}
${latencyPanel(results, hx)}

@@ -189,18 +213,2 @@ ${errorsPanel(results, hx)}

function bandwidthPanel (results, hx) {
return hx`
<div class='object bandwidthBar'>
<div class='heading' onclick="growDiv(this)">
<h2 class='symbol'>-</h2>
<h2>Bandwidth Comparison Chart</h2>
</div>
<div class='content graph'>
<div class='measuringWrapper'>
<div class="chart-bandwidth-linechart ct-perfect-fourth"></div>
</div>
</div>
</div>
`
}
function latencyPanel (results, hx) {

@@ -207,0 +215,0 @@ return hx`

@@ -18,9 +18,15 @@ 'use strict'

var seriesValues = []
var compareValues = []
var compareResults = []
const reducer = (accumulator, currentValue) => accumulator + currentValue
labels.forEach(function (label) {
if (results[label] !== 0) {
compare.forEach(function (value) { compareValues.push(value[label]) })
compareResults[label] = compareValues.reduce(reducer)
if (results[label] !== 0 || compareResults[label] !== 0) {
nonZeros.push(label)
seriesValues.push(results[label])
compareValues = []
seriesValues.push(compareResults[label] + results[label])
}
})
var total = seriesValues.reduce(function (v, x) { return v + x }, 0)
var total = seriesValues.reduce(reducer)
var options = {

@@ -30,3 +36,3 @@ fullWidth: true,

labelInterpolationFnc: function (value) {
return value + ' (' + Math.round(results[value] / total * 100) + '%)'
return value + ' (' + Math.round((results[value] + compareResults[value]) / total * 100) + '%)'
}

@@ -70,12 +76,26 @@ }

var lineValues = [results.latency.min, results.latency.average,
results.latency.p50, results.latency.p75,
results.latency.p90, results.latency.p99, results.latency.p999, results.latency.p9999, results.latency.p99999]
chartist.Bar('.ct-bar', {
labels: ['min', 'average', '50%', '75%', '90%', '99%', '99.9%', '99.99%', '99.999%'],
series: [lineValues]
}, lineOptions)
results.latency.p50, results.latency.p75,
results.latency.p90, results.latency.p99, results.latency.p99_9]
// if compare array isn't used, return early
if (!compare) return
if (compare) {
compare.forEach(function (value) {
compareValues.push([value.latency.min, value.latency.average,
value.latency.p50, value.latency.p75,
value.latency.p90, value.latency.p99, value.latency.p99_9])
})
compareValues.push(lineValues)
chartist.Bar('.ct-bar', {
labels: ['min', 'average', '50%', '75%', '90%', '99%', '99.9%'],
series: compareValues.reverse()
}, lineOptions)
} else {
chartist.Bar('.ct-bar', {
labels: ['min', 'average', '50%', '75%', '90%', '99%', '99.9%'],
series: [lineValues]
}, lineOptions)
// if compare array isn't used, return early
return
}
var requestOptions = {

@@ -94,4 +114,2 @@ fullWidth: true,

var compareRequestLabels = []
compareRequestValues.push(results.requests.average)
compareRequestLabels.push(results.finish)
compare.forEach(function (value) {

@@ -101,2 +119,4 @@ compareRequestValues.push(value.requests.average)

})
compareRequestValues.push(results.requests.average)
compareRequestLabels.push(results.finish)
chartist.Line('.chart-request-linechart', {

@@ -107,26 +127,2 @@ labels: compareRequestLabels.reverse(),

var bandwidthOptions = {
fullWidth: true,
height: 450,
axisY: {
offset: 100,
labelInterpolationFnc: function (value) {
return prettyBytes(value) + '/sec'
}
},
low: 0
}
var compareBandwidthValues = []
var compareBandwidthLabels = []
compareBandwidthValues.push(results.requests.average)
compareBandwidthLabels.push(results.finish)
compare.forEach(function (value) {
compareBandwidthValues.push(value.requests.average)
compareBandwidthLabels.push(value.finish)
})
chartist.Line('.chart-bandwidth-linechart', {
labels: compareBandwidthLabels.reverse(),
series: [compareBandwidthValues.reverse()]
}, bandwidthOptions)
var latencyOptions = {

@@ -145,4 +141,2 @@ fullWidth: true,

var compareLatencyLabels = []
compareLatencyValues.push(results.latency.average)
compareLatencyLabels.push(results.finish)
compare.forEach(function (value) {

@@ -152,2 +146,4 @@ compareLatencyValues.push(value.latency.average)

})
compareLatencyValues.push(results.latency.average)
compareLatencyLabels.push(results.finish)
chartist.Line('.chart-latency-linechart', {

@@ -169,5 +165,2 @@ labels: compareLatencyLabels.reverse(),

var compareTimeoutValues = []
compareErrorValues.push(results.errors - results.timeouts)
compareTimeoutValues.push(results.timeouts)
compareErrorLabels.push(results.finish)
compare.forEach(function (value) {

@@ -178,2 +171,5 @@ compareErrorValues.push(value.errors - value.timeouts)

})
compareErrorValues.push(results.errors - results.timeouts)
compareTimeoutValues.push(results.timeouts)
compareErrorLabels.push(results.finish)
chartist.Bar('.chart-error-barchart', {

@@ -180,0 +176,0 @@ labels: compareErrorLabels.reverse(),

@@ -16,8 +16,8 @@ 'use strict'

function datestuff (date) {
return moment(date).format('MMMM Do YYYY, h:mm:ss a')
return moment(date).format('DD-MMM-YYYY, HH:mm:ss')
}
lab.test('Report output should contain a start and finish time', (done) => {
expect(report).to.contain(datestuff(new Date(sampleResult.start).toString()))
expect(report).to.contain(datestuff(new Date(sampleResult.finish).toString()))
expect(report).to.contain(datestuff(new Date(sampleResult.start)))
expect(report).to.contain(datestuff(new Date(sampleResult.finish)))
done()

@@ -24,0 +24,0 @@ })

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc