Skip to content

Instantly share code, notes, and snippets.

@mrtcmn
mrtcmn / compress.compare.js
Created August 1, 2023 14:08
Brotli compression params compare
const zlib = require('zlib');
const fs = require('fs');
const { performance } = require('perf_hooks');
const filePath = './output.fixture.json'; // Change this to your file
const outputPath = './compressed.br';
// Weight for time and size in the calculation. Must be between 0 and 1.
const timeWeight = 0.5; // weight for time
const sizeWeight = 1 - timeWeight; // weight for size