aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/tar/node_modules/minipass/bench/lib
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/tar/node_modules/minipass/bench/lib')
-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
6 files changed, 102 insertions, 0 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
new file mode 100644
index 0000000000..8e7841a87c
--- /dev/null
+++ b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js
@@ -0,0 +1,11 @@
+'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
new file mode 100644
index 0000000000..6a021084c4
--- /dev/null
+++ b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js
@@ -0,0 +1,12 @@
+'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
new file mode 100644
index 0000000000..1d2d24026d
--- /dev/null
+++ b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js
@@ -0,0 +1,11 @@
+'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
new file mode 100644
index 0000000000..13f6e916b9
--- /dev/null
+++ b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js
@@ -0,0 +1,12 @@
+'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
new file mode 100644
index 0000000000..bd1593299a
--- /dev/null
+++ b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/numbers.js
@@ -0,0 +1,41 @@
+'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
new file mode 100644
index 0000000000..8d8fe3d80d
--- /dev/null
+++ b/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/timer.js
@@ -0,0 +1,15 @@
+'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)
+ }
+ }
+}