Benchmark update: use modern zlib sync api

This commit is contained in:
desudesutalk 2017-07-20 10:45:08 +00:00 committed by Vitaly Puzrin
parent a1fc42542a
commit dfc3b0e2a1
2 changed files with 3 additions and 66 deletions

View file

@ -2,38 +2,6 @@
var zlib = require('zlib');
exports.async = true;
exports.run = function(data, level, callback) {
//zlib.deflate(new Buffer(data), callback);
var zlibStream = zlib.createDeflate({
/*chunkSize: 128*1024,*/
level: level
});
var buffers = [], nread = 0;
zlibStream.on('error', function(err) {
zlibStream.removeAllListeners();
zlibStream=null;
callback(err);
});
zlibStream.on('data', function(chunk) {
buffers.push(chunk);
nread += chunk.length;
});
zlibStream.on('end', function() {
zlibStream.removeAllListeners();
zlibStream=null;
var buffer = Buffer.concat(buffers);
callback(null);
});
zlibStream.write(data.buffer);
zlibStream.end();
zlib.deflateSync(data.buffer, {level:level});
}

View file

@ -2,37 +2,6 @@
var zlib = require('zlib');
exports.async = true;
exports.run = function(data, level, callback) {
//zlib.inflate(data.deflateBuffer, callback);
var zlibStream = zlib.createInflate({
//chunkSize: 128*1024
});
var buffers = [], nread = 0;
zlibStream.on('error', function(err) {
zlibStream.removeAllListeners();
zlibStream=null;
callback(err);
});
zlibStream.on('data', function(chunk) {
buffers.push(chunk);
nread += chunk.length;
});
zlibStream.on('end', function() {
zlibStream.removeAllListeners();
zlibStream=null;
var buffer = Buffer.concat(buffers);
callback(null);
});
zlibStream.write(data.deflateBuffer);
zlibStream.end();
exports.run = function(data) {
zlib.inflateSync(data.deflateBuffer);
}