Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: switch to chromium's zlib implementation #31201

Merged
merged 1 commit into from Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions benchmark/zlib/createInflate.js
@@ -0,0 +1,32 @@
'use strict';
const common = require('../common.js');
const zlib = require('zlib');

const bench = common.createBenchmark(main, {
inputLen: [16 * 1024 * 1024],
chunkLen: [1024],
n: [1e2]
});

function main({ n, inputLen, chunkLen }) {
const input = zlib.deflateSync(Buffer.alloc(inputLen, 'a'));

let i = 0;
bench.start();
(function next() {
let p = 0;
const inflater = zlib.createInflate();
inflater.resume();
inflater.on('finish', () => {
if (i++ === n)
return bench.end(n);
next();
});

(function nextChunk() {
if (p >= input.length)
return inflater.end();
inflater.write(input.slice(p, p += chunkLen), nextChunk);
})();
})();
}
37 changes: 37 additions & 0 deletions benchmark/zlib/inflate.js
@@ -0,0 +1,37 @@
'use strict';
const common = require('../common.js');
const zlib = require('zlib');

const bench = common.createBenchmark(main, {
method: ['inflate', 'inflateSync'],
inputLen: [1024],
n: [4e5]
});

function main({ n, method, inputLen }) {
const chunk = zlib.deflateSync(Buffer.alloc(inputLen, 'a'));

let i = 0;
switch (method) {
// Performs `n` single inflate operations
case 'inflate':
const inflate = zlib.inflate;
bench.start();
(function next(err, result) {
if (i++ === n)
return bench.end(n);
inflate(chunk, next);
})();
break;
// Performs `n` single inflateSync operations
case 'inflateSync':
const inflateSync = zlib.inflateSync;
bench.start();
for (; i < n; ++i)
inflateSync(chunk);
bench.end(n);
break;
default:
throw new Error('Unsupported inflate method');
}
}
5 changes: 4 additions & 1 deletion common.gypi
Expand Up @@ -202,7 +202,10 @@
'RuntimeLibrary': '<(MSVC_runtimeType)',
'RuntimeTypeInfo': 'false',
}
}
},
'xcode_settings': {
'GCC_OPTIMIZATION_LEVEL': '3', # stop gyp from defaulting to -Os
},
}
},

Expand Down