-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: switch to chromium's zlib implementation
This implementation provides optimizations not included upstream. PR-URL: #31201 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information
1 parent
2eeaa5c
commit bf7097c
Showing
266 changed files
with
11,399 additions
and
39,711 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
})(); | ||
})(); | ||
} |
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,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'); | ||
} | ||
} |
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
Oops, something went wrong.