summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/tar/node_modules/minipass/bench
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/tar/node_modules/minipass/bench')
-rw-r--r--deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js11
-rw-r--r--deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js12
-rw-r--r--deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js11
-rw-r--r--deps/npm/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js12
-rw-r--r--deps/npm/node_modules/tar/node_modules/minipass/bench/lib/numbers.js41
-rw-r--r--deps/npm/node_modules/tar/node_modules/minipass/bench/lib/timer.js15
-rw-r--r--deps/npm/node_modules/tar/node_modules/minipass/bench/test.js160
7 files changed, 0 insertions, 262 deletions
diff --git a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js
deleted file mode 100644
index 8e7841a87c..0000000000
--- a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict'
-const MiniPass = require('../..')
-
-module.exports = class ExtendMiniPass extends MiniPass {
- constructor (opts) {
- super(opts)
- }
- write (data, encoding) {
- return super.write(data, encoding)
- }
-}
diff --git a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js
deleted file mode 100644
index 6a021084c4..0000000000
--- a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict'
-const through2 = require('through2')
-module.exports = function (opt) {
- return opt.objectMode
- ? through2.obj(func)
- : through2(func)
-
- function func (data, enc, done) {
- this.push(data, enc)
- done()
- }
-}
diff --git a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js
deleted file mode 100644
index 1d2d24026d..0000000000
--- a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict'
-const stream = require('stream')
-module.exports = class ExtendTransform extends stream.Transform {
- constructor (opts) {
- super(opts)
- }
- _transform (data, enc, done) {
- this.push(data, enc)
- done()
- }
-}
diff --git a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js
deleted file mode 100644
index 13f6e916b9..0000000000
--- a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict'
-const EE = require('events').EventEmitter
-
-module.exports = class NullSink extends EE {
- write (data, encoding, next) {
- if (next) next()
- return true
- }
- end () {
- this.emit('finish')
- }
-}
diff --git a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/numbers.js b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/numbers.js
deleted file mode 100644
index bd1593299a..0000000000
--- a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/numbers.js
+++ /dev/null
@@ -1,41 +0,0 @@
-'use strict'
-const stream = require('stream')
-
-const numbers = new Array(1000).join(',').split(',').map((v, k) => k)
-let acc = ''
-const strings = numbers.map(n => acc += n)
-const bufs = strings.map(s => new Buffer(s))
-const objs = strings.map(s => ({ str: s }))
-
-module.exports = class Numbers {
- constructor (opt) {
- this.objectMode = opt.objectMode
- this.encoding = opt.encoding
- this.ii = 0
- this.done = false
- }
- pipe (dest) {
- this.dest = dest
- this.go()
- return dest
- }
-
- go () {
- let flowing = true
- while (flowing) {
- if (this.ii >= 1000) {
- this.dest.end()
- this.done = true
- flowing = false
- } else {
- flowing = this.dest.write(
- (this.objectMode ? objs
- : this.encoding ? strings
- : bufs)[this.ii++])
- }
- }
-
- if (!this.done)
- this.dest.once('drain', _ => this.go())
- }
-}
diff --git a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/timer.js b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/timer.js
deleted file mode 100644
index 8d8fe3d80d..0000000000
--- a/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/timer.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict'
-module.exports = _ => {
- const start = process.hrtime()
- return _ => {
- const end = process.hrtime(start)
- const ms = Math.round(end[0]*1e6 + end[1]/1e3)/1e3
- if (!process.env.isTTY)
- console.log(ms)
- else {
- const s = Math.round(end[0]*10 + end[1]/1e8)/10
- const ss = s <= 1 ? '' : ' (' + s + 's)'
- console.log('%d%s', ms, ss)
- }
- }
-}
diff --git a/deps/npm/node_modules/tar/node_modules/minipass/bench/test.js b/deps/npm/node_modules/tar/node_modules/minipass/bench/test.js
deleted file mode 100644
index 29c9fd07d6..0000000000
--- a/deps/npm/node_modules/tar/node_modules/minipass/bench/test.js
+++ /dev/null
@@ -1,160 +0,0 @@
-'use strict'
-
-const iterations = +process.env.BENCH_TEST_ITERATION || 100
-const testCount = +process.env.BENCH_TEST_COUNT || 20
-
-const tests = [
- 'baseline',
- 'minipass',
- 'extend-minipass',
- 'through2',
- 'extend-through2',
- 'passthrough',
- 'extend-transform'
-]
-
-const manyOpts = [ 'many', 'single' ]
-const typeOpts = [ 'buffer', 'string', 'object' ]
-
-const main = () => {
- const spawn = require('child_process').spawn
- const node = process.execPath
-
- const results = {}
-
- const testSet = []
- tests.forEach(t =>
- manyOpts.forEach(many =>
- typeOpts.forEach(type =>
- new Array(testCount).join(',').split(',').forEach(() =>
- t !== 'baseline' || (many === 'single' && type === 'object')
- ? testSet.push([t, many, type]) : null))))
-
- let didFirst = false
- const mainRunTest = t => {
- if (!t)
- return afterMain(results)
-
- const k = t.join('\t')
- if (!results[k]) {
- results[k] = []
- if (!didFirst)
- didFirst = true
- else
- process.stderr.write('\n')
-
- process.stderr.write(k + ' #')
- } else {
- process.stderr.write('#')
- }
-
- const c = spawn(node, [__filename].concat(t), {
- stdio: [ 'ignore', 'pipe', 2 ]
- })
- let out = ''
- c.stdout.on('data', c => out += c)
- c.on('close', (code, signal) => {
- if (code || signal)
- throw new Error('failed: ' + code + ' ' + signal)
- results[k].push(+out)
- mainRunTest(testSet.shift())
- })
- }
-
- mainRunTest(testSet.shift())
-}
-
-const afterMain = results => {
- console.log('test\tmany\ttype\tops/s\tmean\tmedian\tmax\tmin' +
- '\tstdev\trange\traw')
- // get the mean, median, stddev, and range of each test
- Object.keys(results).forEach(test => {
- const k = results[test].sort((a, b) => a - b)
- const min = k[0]
- const max = k[ k.length - 1 ]
- const range = max - min
- const sum = k.reduce((a,b) => a + b, 0)
- const mean = sum / k.length
- const ops = iterations / mean * 1000
- const devs = k.map(n => n - mean).map(n => n * n)
- const avgdev = devs.reduce((a,b) => a + b, 0) / k.length
- const stdev = Math.pow(avgdev, 0.5)
- const median = k.length % 2 ? k[Math.floor(k.length / 2)] :
- (k[k.length/2] + k[k.length/2+1])/2
- console.log(
- '%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s', test, round(ops),
- round(mean), round(median),
- max, min, round(stdev), round(range),
- k.join('\t'))
- })
-}
-
-const round = num => Math.round(num * 1000)/1000
-
-const test = (testname, many, type) => {
- const timer = require('./lib/timer.js')
- const Class = getClass(testname)
-
- const done = timer()
- runTest(Class, many, type, iterations, done)
-}
-
-// don't blow up the stack! loop unless deferred
-const runTest = (Class, many, type, iterations, done) => {
- const Nullsink = require('./lib/nullsink.js')
- const Numbers = require('./lib/numbers.js')
- const opt = {}
- if (type === 'string')
- opt.encoding = 'utf8'
- else if (type === 'object')
- opt.objectMode = true
-
- while (iterations--) {
- let finished = false
- let inloop = true
- const after = iterations === 0 ? done
- : () => {
- if (iterations === 0)
- done()
- else if (inloop)
- finished = true
- else
- runTest(Class, many, type, iterations, done)
- }
-
- const out = new Nullsink().on('finish', after)
- let sink = Class ? new Class(opt) : out
-
- if (many && Class)
- sink = sink
- .pipe(new Class(opt))
- .pipe(new Class(opt))
- .pipe(new Class(opt))
- .pipe(new Class(opt))
-
- if (sink !== out)
- sink.pipe(out)
-
- new Numbers(opt).pipe(sink)
-
- // keep tight-looping if the stream is done already
- if (!finished) {
- inloop = false
- break
- }
- }
-}
-
-const getClass = testname =>
- testname === 'through2' ? require('through2').obj
- : testname === 'extend-through2' ? require('./lib/extend-through2.js')
- : testname === 'minipass' ? require('../')
- : testname === 'extend-minipass' ? require('./lib/extend-minipass.js')
- : testname === 'passthrough' ? require('stream').PassThrough
- : testname === 'extend-transform' ? require('./lib/extend-transform.js')
- : null
-
-if (!process.argv[2])
- main()
-else
- test(process.argv[2], process.argv[3] === 'many', process.argv[4])