From b7da5b79c300b2d5abf6658ba3fa8edf916f05cc Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 10 Dec 2018 15:48:50 +0100 Subject: benchmark,test: add brotli Co-authored-by: Hackzzila PR-URL: https://github.com/nodejs/node/pull/24938 Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina Reviewed-By: Jan Krems Reviewed-By: James M Snell Reviewed-By: Myles Borins Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Daniel Bevenius --- benchmark/zlib/creation.js | 3 ++- benchmark/zlib/pipe.js | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'benchmark') diff --git a/benchmark/zlib/creation.js b/benchmark/zlib/creation.js index 4984bf1a86..f23759fa0e 100644 --- a/benchmark/zlib/creation.js +++ b/benchmark/zlib/creation.js @@ -4,7 +4,8 @@ const zlib = require('zlib'); const bench = common.createBenchmark(main, { type: [ - 'Deflate', 'DeflateRaw', 'Inflate', 'InflateRaw', 'Gzip', 'Gunzip', 'Unzip' + 'Deflate', 'DeflateRaw', 'Inflate', 'InflateRaw', 'Gzip', 'Gunzip', 'Unzip', + 'BrotliCompress', 'BrotliDecompress' ], options: ['true', 'false'], n: [5e5] diff --git a/benchmark/zlib/pipe.js b/benchmark/zlib/pipe.js index 9b05749bbb..6a1c427bc8 100644 --- a/benchmark/zlib/pipe.js +++ b/benchmark/zlib/pipe.js @@ -6,15 +6,18 @@ const zlib = require('zlib'); const bench = common.createBenchmark(main, { inputLen: [1024], duration: [5], - type: ['string', 'buffer'] + type: ['string', 'buffer'], + algorithm: ['gzip', 'brotli'] }); -function main({ inputLen, duration, type }) { +function main({ inputLen, duration, type, algorithm }) { const buffer = Buffer.alloc(inputLen, fs.readFileSync(__filename)); const chunk = type === 'buffer' ? buffer : buffer.toString('utf8'); - const input = zlib.createGzip(); - const output = zlib.createGunzip(); + const input = algorithm === 'gzip' ? + zlib.createGzip() : zlib.createBrotliCompress(); + const output = algorithm === 'gzip' ? + zlib.createGunzip() : zlib.createBrotliDecompress(); let readFromOutput = 0; input.pipe(output); -- cgit v1.2.3