-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.js
24 lines (23 loc) · 950 Bytes
/
benchmark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var benchmark = require('async-benchmark')
, concat = require('concat-stream')
, test = require('tape')
, createStream = require('./significant-stream')
, runTest = function (input, options, done) {
var stream = createStream(options)
stream.pipe(concat({ encoding: 'object' }, done))
input.forEach(function (data) { stream.write(data) })
stream.end()
}
, inputs = [
Array(500).join('A'),
Array(500).join('B') + Array(100).join('C'),
Array(500).join('B') + Array(100).join('C') + 'beep boop',
]
, benchCache = function (done) { runTest(inputs, { cache: { max: 500 } }, done) }
, benchNoCache = function (done) { runTest(inputs, {}, done) }
benchmark('SignificantStream with cache', benchCache, function (err, event) {
console.log(event.target.toString())
benchmark('SignificantStream no cache', benchNoCache, function (err, event) {
console.log(event.target.toString())
})
})