1
|
#!/usr/bin/env node
|
2
|
var hpack = require('../');
|
3
|
|
4
|
var options = {
|
5
|
table: { size: 1024 }
|
6
|
};
|
7
|
|
8
|
var compressor = hpack.compressor.create(options);
|
9
|
|
10
|
var vector = [];
|
11
|
for (var i = 0; i < 1024; i++) {
|
12
|
vector.push({
|
13
|
name: 'kind-of-big-header-name__',
|
14
|
value: 'not-so-small value yes!',
|
15
|
huffman: true,
|
16
|
neverIndex: true
|
17
|
});
|
18
|
}
|
19
|
compressor.write(vector);
|
20
|
var input = compressor.read();
|
21
|
|
22
|
console.time('decompressor');
|
23
|
for (var i = 0; i < 2000; i++) {
|
24
|
var decompressor = hpack.decompressor.create(options);
|
25
|
|
26
|
decompressor.write(input);
|
27
|
decompressor.execute();
|
28
|
while (true) {
|
29
|
var chunk = decompressor.read();
|
30
|
if (!chunk)
|
31
|
break;
|
32
|
}
|
33
|
}
|
34
|
console.timeEnd('decompressor');
|