Skip to content

Commit

Permalink
Updated benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jan 25, 2017
1 parent 0e368b6 commit 9bccd72
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions benchmarks/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var bench = require('fastbench')
var syncthrough = require('../')
var through2 = require('through2')
var through = require('through')
var data = Buffer.from('hello')

function write (i, s) {
Expand All @@ -28,6 +29,21 @@ function benchThrough2 (done) {
write(0, stream)
}

var lastDone = null
function benchThrough (done) {
var stream = through()
lastDone = done
stream.on('data', noop)
stream.on('end', next)

write(0, stream)
}

function next () {
// needed to avoid a max stack call exception
process.nextTick(lastDone)
}

function benchSyncThrough (done) {
var stream = syncthrough()

Expand All @@ -41,6 +57,7 @@ function noop () {}

var run = bench([
benchThrough2,
benchThrough,
benchSyncThrough
], 10000)

Expand Down

0 comments on commit 9bccd72

Please sign in to comment.