Added level param to benchmarks

This commit is contained in:
Vitaly Puzrin 2014-02-18 04:32:01 +04:00
parent 822310eb43
commit 7deacf94a3
5 changed files with 11 additions and 9 deletions

View file

@ -2,6 +2,7 @@
'use strict';
var LEVEL = 6;
var path = require('path');
var fs = require('fs');
@ -69,12 +70,12 @@ fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) {
fn: function (deferred) {
if (!!impl.code.async) {
impl.code.run(content, function() {
impl.code.run(content, LEVEL, function() {
deferred.resolve();
return;
});
} else {
impl.code.run(content, deferred);
impl.code.run(content, LEVEL);
return;
}
}

View file

@ -2,6 +2,6 @@
var deflate = require('./deflate');
exports.run = function(data) {
return deflate(data);
exports.run = function(data, level) {
return deflate(data, level);
}

View file

@ -3,5 +3,6 @@
var deflate = require('./deflate');
exports.run = function(data) {
// Compression levels not supported. Use unknown defaults always
return deflate(data);
}

View file

@ -2,8 +2,8 @@
var pako = require('../../../index.js');
exports.run = function(data) {
exports.run = function(data, level) {
return pako.deflate(data, {
level: 0
level: level
});
}

View file

@ -4,12 +4,12 @@ var zlib = require('zlib');
exports.async = true;
exports.run = function(data, callback) {
exports.run = function(data, level, callback) {
//zlib.deflate(new Buffer(data), callback);
var zlibStream = zlib.createDeflate({
/*chunkSize: 128*1024,
level: 0*/
/*chunkSize: 128*1024,*/
level: level
});
var buffers = [], nread = 0;