cdb
This commit is contained in:
24
lib/assets/javascripts/cdb/scripts/check_size.js
Normal file
24
lib/assets/javascripts/cdb/scripts/check_size.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* this utility reports the size of a layergroup compressed
|
||||
* usage:
|
||||
* node check_size.js layergroup.json
|
||||
*/
|
||||
|
||||
var lzma = require("lzma").LZMA();
|
||||
var fs = require('fs');
|
||||
function _array2hex (byteArr) {
|
||||
var encoded = [];
|
||||
for(var i = 0; i < byteArr.length; ++i) {
|
||||
encoded.push(String.fromCharCode(byteArr[i] + 128));
|
||||
}
|
||||
buffer = new Buffer(encoded.join(''), 'binary');
|
||||
return buffer.toString('base64');
|
||||
}
|
||||
|
||||
var str = fs.readFileSync(process.argv[2]);
|
||||
lzma.compress(str, 1, function(result) {
|
||||
console.log("size (raw/compressed/base64 compressed): ", str.length, "/", result.length, "/", _array2hex(result).length);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user