Skip to content

Instantly share code, notes, and snippets.

@gireeshpunathil
Created April 17, 2018 13:22
Show Gist options
  • Save gireeshpunathil/a2fc2904675906f15efd3c93f7238e45 to your computer and use it in GitHub Desktop.
Save gireeshpunathil/a2fc2904675906f15efd3c93f7238e45 to your computer and use it in GitHub Desktop.
var http = require('http')
var string = 'http://localhost:25000'
for(var count=0; count < process.argv[2]; count++) {
http.get(string, (res) => {
res.on('data', (d) => {
});
res.on('end', () => {
})
})
}
var http = require('http')
let count = 0
let intvl = 0
var data = 'g'.repeat(1024 * 1024 * 10)
var bytes = data.length
var server = http.createServer(function(req, res) {
res.end(data, () => {
count++;
})
})
server.listen(25000, () => {
console.log('server listening...')
})
setInterval(() => {
intvl++
console.log(`${bytes * count / (intvl * 1024 * 1024)} mbps`)
}, 1000)
@gireeshpunathil
Copy link
Author

usage:

$ node server.js
$ node client.js 200 in another terminal

output:
0 mbps
0 mbps
0 mbps
87.5 mbps
130 mbps
321.6666666666667 mbps
285.7142857142857 mbps
250 mbps
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment