This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 2f34bf0 as of 2017-06-14. This is an automatically created merge. For any problems please contact @kunalspathak.
- Loading branch information
Showing
98 changed files
with
1,449 additions
and
1,073 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
var common = require('../common.js'); | ||
var Transform = require('stream').Transform; | ||
var inherits = require('util').inherits; | ||
|
||
var bench = common.createBenchmark(main, { | ||
n: [1e6] | ||
}); | ||
|
||
function MyTransform() { | ||
Transform.call(this); | ||
} | ||
inherits(MyTransform, Transform); | ||
MyTransform.prototype._transform = function() {}; | ||
|
||
function main(conf) { | ||
var n = +conf.n; | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; ++i) | ||
new MyTransform(); | ||
bench.end(n); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
var common = require('../common.js'); | ||
var zlib = require('zlib'); | ||
|
||
var bench = common.createBenchmark(main, { | ||
type: [ | ||
'Deflate', 'DeflateRaw', 'Inflate', 'InflateRaw', 'Gzip', 'Gunzip', 'Unzip' | ||
], | ||
options: ['true', 'false'], | ||
n: [5e5] | ||
}); | ||
|
||
function main(conf) { | ||
var n = +conf.n; | ||
var fn = zlib['create' + conf.type]; | ||
if (typeof fn !== 'function') | ||
throw new Error('Invalid zlib type'); | ||
var i = 0; | ||
|
||
if (conf.options === 'true') { | ||
var opts = {}; | ||
bench.start(); | ||
for (; i < n; ++i) | ||
fn(opts); | ||
bench.end(n); | ||
} else { | ||
bench.start(); | ||
for (; i < n; ++i) | ||
fn(); | ||
bench.end(n); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict'; | ||
var common = require('../common.js'); | ||
var zlib = require('zlib'); | ||
|
||
var bench = common.createBenchmark(main, { | ||
method: ['createDeflate', 'deflate', 'deflateSync'], | ||
inputLen: [1024], | ||
n: [4e5] | ||
}); | ||
|
||
function main(conf) { | ||
var n = +conf.n; | ||
var method = conf.method; | ||
var chunk = Buffer.alloc(+conf.inputLen, 'a'); | ||
|
||
var i = 0; | ||
switch (method) { | ||
// Performs `n` writes for a single deflate stream | ||
case 'createDeflate': | ||
var deflater = zlib.createDeflate(); | ||
deflater.resume(); | ||
deflater.on('finish', () => { | ||
bench.end(n); | ||
}); | ||
|
||
bench.start(); | ||
(function next() { | ||
if (i++ === n) | ||
return deflater.end(); | ||
deflater.write(chunk, next); | ||
})(); | ||
break; | ||
// Performs `n` single deflate operations | ||
case 'deflate': | ||
var deflate = zlib.deflate; | ||
bench.start(); | ||
(function next(err, result) { | ||
if (i++ === n) | ||
return bench.end(n); | ||
deflate(chunk, next); | ||
})(); | ||
break; | ||
// Performs `n` single deflateSync operations | ||
case 'deflateSync': | ||
var deflateSync = zlib.deflateSync; | ||
bench.start(); | ||
for (; i < n; ++i) | ||
deflateSync(chunk); | ||
bench.end(n); | ||
break; | ||
default: | ||
throw new Error('Unsupported deflate method'); | ||
} | ||
} |
Oops, something went wrong.