diff options
author | Brian White <mscdex@mscdex.net> | 2017-05-30 12:56:09 -0400 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-06-13 11:48:59 -0700 |
commit | add4b0ab8cc0ec663cd4623e9032c14830873760 (patch) | |
tree | 97134dcaa2e4aa7406fb4d25a6293cb992049136 /benchmark/zlib/creation.js | |
parent | e5dc934ef6f66edade76720dc7592e9e348db49f (diff) | |
download | android-node-v8-add4b0ab8cc0ec663cd4623e9032c14830873760.tar.gz android-node-v8-add4b0ab8cc0ec663cd4623e9032c14830873760.tar.bz2 android-node-v8-add4b0ab8cc0ec663cd4623e9032c14830873760.zip |
zlib: improve performance
PR-URL: https://github.com/nodejs/node/pull/13322
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'benchmark/zlib/creation.js')
-rw-r--r-- | benchmark/zlib/creation.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/benchmark/zlib/creation.js b/benchmark/zlib/creation.js new file mode 100644 index 0000000000..a207665bd9 --- /dev/null +++ b/benchmark/zlib/creation.js @@ -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); + } +} |