Skip to content

Commit

Permalink
remove variability on string generation (#50)
Browse files Browse the repository at this point in the history
Fixes #47
  • Loading branch information
mcollina committed Oct 1, 2020
1 parent 8fc9d70 commit 1178b14
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ const dummyConsole = new Console(fs.createWriteStream('/dev/null'))

const MAX = 10000

function str () {
let res = ''
let str = ''

for (let i = 0; i < 10; i++) {
res += 'hello'
}

return res
for (let i = 0; i < 10; i++) {
str += 'hello'
}

setTimeout(doBench, 100)
Expand All @@ -31,36 +27,36 @@ const run = bench([
function benchSonic (cb) {
sonic.once('drain', cb)
for (let i = 0; i < MAX; i++) {
sonic.write(str())
sonic.write(str)
}
},
function benchSonicSync (cb) {
sonicSync.once('drain', cb)
for (let i = 0; i < MAX; i++) {
sonicSync.write(str())
sonicSync.write(str)
}
},
function benchSonic4k (cb) {
sonic4k.once('drain', cb)
for (let i = 0; i < MAX; i++) {
sonic4k.write(str())
sonic4k.write(str)
}
},
function benchSonicSync4k (cb) {
sonicSync4k.once('drain', cb)
for (let i = 0; i < MAX; i++) {
sonicSync4k.write(str())
sonicSync4k.write(str)
}
},
function benchCore (cb) {
core.once('drain', cb)
for (let i = 0; i < MAX; i++) {
core.write(str())
core.write(str)
}
},
function benchConsole (cb) {
for (let i = 0; i < MAX; i++) {
dummyConsole.log(str())
dummyConsole.log(str)
}
setImmediate(cb)
}
Expand Down

0 comments on commit 1178b14

Please sign in to comment.