Created
February 15, 2016 14:24
-
-
Save serby/ea40262989018c375dcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const size = 74 * 1024 | |
var packet = { name: 'Paul Serby', email: '[email protected]' } | |
, packetSize = JSON.stringify(packet).length | |
, count = Math.round(size / packetSize) | |
, buffer = [] | |
, i | |
, time = Date.now() | |
, bigPacket = Array(size).fill('X') | |
for (i = 0; i < count; i++) { | |
packet.random = Math.random() | |
buffer.push(JSON.stringify(packet)) | |
} | |
for (i = 0; i < count; i++) { | |
process.stderr.write(buffer[i]) | |
} | |
console.log('\n\nSmall packets %d x %d bytes (total: %d bytes) in %dms' | |
, count, packetSize, count * packetSize, Date.now() - time) | |
time = Date.now() | |
process.stderr.write(JSON.stringify(bigPacket)) | |
console.log('Single write of %d bytes in %dms', size, Date.now() - time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment