source: trip-planner-front/node_modules/hdr-histogram-js/dist/bench/histogram-decoding.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const benny_1 = require("benny");
4const index_1 = require("../index");
5const encoding_1 = require("../encoding");
6const wasm_1 = require("../wasm");
7wasm_1.initWebAssembly().then(() => {
8 const randomInteger = (max = Number.MAX_SAFE_INTEGER) => Math.floor(Math.random() * max);
9 const options = { initCount: 1000 };
10 benny_1.default.suite("Histogram decoding", benny_1.default.add("Int32Histogram", () => {
11 const histogram = index_1.build();
12 for (let index = 0; index < 1024; index++) {
13 histogram.recordValueWithCount(randomInteger(), randomInteger(100));
14 }
15 const b64 = encoding_1.encodeIntoCompressedBase64(histogram);
16 return () => {
17 encoding_1.decodeFromCompressedBase64(b64, 32, false).destroy();
18 };
19 }, options), benny_1.default.add("WASM 32B Histogram", () => {
20 const histogram = index_1.build();
21 for (let index = 0; index < 1024; index++) {
22 histogram.recordValueWithCount(randomInteger(), randomInteger(100));
23 }
24 const b64 = encoding_1.encodeIntoCompressedBase64(histogram);
25 histogram.destroy();
26 return () => {
27 encoding_1.decodeFromCompressedBase64(b64, 32, true).destroy();
28 };
29 }, options), benny_1.default.add("Packed Histogram", () => {
30 const histogram = index_1.build();
31 for (let index = 0; index < 1024; index++) {
32 histogram.recordValueWithCount(randomInteger(), randomInteger(100));
33 }
34 const b64 = encoding_1.encodeIntoCompressedBase64(histogram);
35 return () => {
36 encoding_1.decodeFromCompressedBase64(b64, "packed", false).destroy();
37 };
38 }, options), benny_1.default.add("WASM Packed Histogram", () => {
39 const histogram = index_1.build({
40 bitBucketSize: "packed",
41 useWebAssembly: true
42 });
43 for (let index = 0; index < 1024; index++) {
44 histogram.recordValueWithCount(randomInteger(), randomInteger(100));
45 }
46 const b64 = encoding_1.encodeIntoCompressedBase64(histogram);
47 histogram.destroy();
48 return () => {
49 encoding_1.decodeFromCompressedBase64(b64, "packed", true).destroy();
50 };
51 }, options), benny_1.default.complete(), benny_1.default.save({ file: "decoding", format: "chart.html" }));
52});
53//# sourceMappingURL=histogram-decoding.js.map
Note: See TracBrowser for help on using the repository browser.