benchmark 692 B

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