Changed benchmark data formats pass

This commit is contained in:
Vitaly Puzrin 2014-02-27 12:00:58 +04:00
parent 0b21c5b402
commit 652ff4d794
5 changed files with 22 additions and 8 deletions

View file

@ -11,6 +11,8 @@ var Benchmark = require('benchmark');
var ansi = require('ansi');
var cursor = ansi(process.stdout);
var pako = require('../');
var IMPLS_DIRECTORY = path.join(__dirname, 'implementations');
var IMPLS_PATHS = {};
@ -35,9 +37,21 @@ var SAMPLES = [];
fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) {
var filepath = path.join(SAMPLES_DIRECTORY, sample),
extname = path.extname(filepath),
basename = path.basename(filepath, extname),
content = new Uint8Array(fs.readFileSync(filepath)),
title = util.format('%s (%d bytes)', sample, content.length);
basename = path.basename(filepath, extname);
var content = {}; // raw/compressed data in different formats
content.buffer = fs.readFileSync(filepath);
content.typed = new Uint8Array(content.buffer);
content.deflateTyped = pako.deflate(content.typed, { level: LEVEL });
content.deflateBuffer = new Buffer(content.deflateTyped);
content.deflateRawTyped = pako.deflateRaw(content.typed, { level: LEVEL });
content.deflateRawBuffer = new Buffer(content.deflateRawTyped);
var title = util.format('(%d bytes raw / ~%d bytes compressed)', content.typed.length, content.deflateTyped.length);
function onComplete() {
cursor.write('\n');
@ -47,7 +61,7 @@ fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) {
var suite = new Benchmark.Suite(title, {
onStart: function onStart() {
console.log('\nSample: %s', sample);
console.log('\nSample: %s %s', sample, title);
},
onComplete: onComplete

View file

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

View file

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

View file

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

View file

@ -34,6 +34,6 @@ exports.run = function(data, level, callback) {
callback(null);
});
zlibStream.write(new Buffer(data));
zlibStream.write(data.buffer);
zlibStream.end();
}