Skip to content

Instantly share code, notes, and snippets.

@PierBover
Created June 15, 2019 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PierBover/e8429e602d8b5a4cd113e18098165cc2 to your computer and use it in GitHub Desktop.
Save PierBover/e8429e602d8b5a4cd113e18098165cc2 to your computer and use it in GitHub Desktop.
Node Kbps
const https = require('https');
const fs = require('fs');
const writeStream = fs.createWriteStream("./log.xls");
let bytes = 0;
https.get('https://edge.mixlr.com/channel/udesp', (resp) => {
resp.on('data', (buffer) => {
bytes += buffer.length;
});
});
setInterval(() => {
const kbps = bytes / 1000;
const time = new Date();
const row = `${time.toTimeString()}\t${kbps} KBs\n`;
console.log(row);
writeStream.write(row);
bytes = 0;
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment