[6a3a178] | 1 | /*
|
---|
| 2 | * This is a TypeScript port of the original Java version, which was written by
|
---|
| 3 | * Gil Tene as described in
|
---|
| 4 | * https://github.com/HdrHistogram/HdrHistogram
|
---|
| 5 | * and released to the public domain, as explained at
|
---|
| 6 | * http://creativecommons.org/publicdomain/zero/1.0/
|
---|
| 7 | */
|
---|
| 8 | import { Int32Histogram, WasmHistogram } from "./index";
|
---|
| 9 | import { initWebAssembly } from "./wasm";
|
---|
| 10 | import {
|
---|
| 11 | encodeIntoCompressedBase64,
|
---|
| 12 | decodeFromCompressedBase64,
|
---|
| 13 | } from "./encoding";
|
---|
| 14 | import Histogram from "./Histogram";
|
---|
| 15 |
|
---|
| 16 | describe("Histogram encoding", () => {
|
---|
| 17 | it("should encode and decode an histogram", () => {
|
---|
| 18 | // given
|
---|
| 19 | const histogram = new Int32Histogram(1, 2, 3);
|
---|
| 20 | histogram.autoResize = true;
|
---|
| 21 | histogram.recordValue(32415);
|
---|
| 22 | // when
|
---|
| 23 | const b64 = encodeIntoCompressedBase64(histogram);
|
---|
| 24 | // then
|
---|
| 25 | const decodedHistogram = decodeFromCompressedBase64(b64);
|
---|
| 26 | expect(decodedHistogram.toJSON()).toStrictEqual(histogram.toJSON());
|
---|
| 27 | });
|
---|
| 28 |
|
---|
| 29 | it("should decode and decompress reading a base64 string", () => {
|
---|
| 30 | // given
|
---|
| 31 | const base64String = "HISTFAAAAB542pNpmSzMwMDAxAABzFCaEUoz2X+AMIKZAEARAtM=";
|
---|
| 32 | // when
|
---|
| 33 | const histogram = decodeFromCompressedBase64(base64String);
|
---|
| 34 | // then
|
---|
| 35 | expect(histogram.mean).toBe(42);
|
---|
| 36 | expect(histogram.totalCount).toBe(1);
|
---|
| 37 | });
|
---|
| 38 |
|
---|
| 39 | it("should decode and decompress a big base64 string", () => {
|
---|
| 40 | // given
|
---|
| 41 | const base64String =
|
---|
| 42 | "HISTFAAACGB42j1WQY4cuRGks7KzWWwOh1NTGo1GEmzBWCx0EAxjsd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gg1Zw++iJBgEpWcGl10sUqFw6hd+vp+S0xOHIqC5fGrRIRq0IxTUZtloyDI9aP8kagP6fmk/us9HEos4YEzrEOCk1BWBtkYk6OXKObwHgMfN81sVnpdliHDPKLDnoWGRJGiK4xPzhjKruu9UYpQYh6ASv0lbe0DOdX6ayAmNEkyFoLv7JoQH6o/+CDoS3xt5wqjSpJhHjtjZr1OCA+Ys5ZDzYx/DL6iI4eG8dr6bOPA7hnbccc53gbPNJHqzgx5zE6/ImJQKMN3OFYe5mQ9qxv/RyvzY854QpIM/AX2/w8xoluoETnnONtvowxZjuPjiLbS61vwydCAu4x2tlfz47U3A75zonNmEHgZbzM3pAIaNuJQYbFMY8GaMjjAyv1PNtLf208c87XPlBEsLVeZ5/HGfWIAwyjodoJwmYMR6HH2SfcVnGnsYbTfPiENP316K8Dr8+K4hpIgdlHBUdgox3jBSk6K0YP9qMBzZzRX0CQgwTYPXBw1IHCQDLeI1kDG/0E0nqOA5+O8EA+XhFytKO1E5MJlZ4dvNY5zzpeHFkhH9K8sS/npFjIZZ8aM4e/NGjUx/BjvCHA0QnkBTHwFqGO2Y+jw24T0rNF/oT3/Zx06P8BChhtKw==";
|
---|
| 43 | // when
|
---|
| 44 | const histogram = decodeFromCompressedBase64(base64String);
|
---|
| 45 | // then
|
---|
| 46 | expect(histogram.totalCount).toBe(10000);
|
---|
| 47 | });
|
---|
| 48 |
|
---|
| 49 | it("should encode and compress an histogram to a base64 string", () => {
|
---|
| 50 | // given
|
---|
| 51 | const histogram = new Int32Histogram(1, 2, 3);
|
---|
| 52 | histogram.recordValue(42);
|
---|
| 53 | // when
|
---|
| 54 | const base64Histogram = encodeIntoCompressedBase64(histogram);
|
---|
| 55 | // then
|
---|
| 56 | expect(base64Histogram).toBe(
|
---|
| 57 | "HISTFAAAAB94nJNpmSzMwMDABMSMQMzMAAGMUJoJxg9mAgA1TQGm"
|
---|
| 58 | );
|
---|
| 59 | });
|
---|
| 60 |
|
---|
| 61 | it("should throw an error when trying to decompress an histogram using V1 encoding", () => {
|
---|
| 62 | // given
|
---|
| 63 | const base64V1EncodingString =
|
---|
| 64 | "HISTIgAAAFd42pNpmazIwMAYxgABTBDKT4GBgdnNYMcCBvsPUBkeBkYGZqA8MwMbAzsDC5DFBCTZgJCDQY1BjkGLQZRBlUEPCB8zWDCYMxgDZZkZhgJgHDibAY8JB/A=";
|
---|
| 65 | // when & then
|
---|
| 66 | expect(() =>
|
---|
| 67 | decodeFromCompressedBase64(base64V1EncodingString)
|
---|
| 68 | ).toThrowError("Encoding not supported");
|
---|
| 69 | });
|
---|
| 70 | });
|
---|
| 71 |
|
---|
| 72 | describe("WASM Histogram encoding", () => {
|
---|
| 73 | let histogram: Histogram;
|
---|
| 74 |
|
---|
| 75 | beforeAll(initWebAssembly);
|
---|
| 76 |
|
---|
| 77 | afterEach(() => {
|
---|
| 78 | if (histogram) {
|
---|
| 79 | histogram.destroy();
|
---|
| 80 | }
|
---|
| 81 | });
|
---|
| 82 |
|
---|
| 83 | it("should decode and decompress a big base64 string", () => {
|
---|
| 84 | // given
|
---|
| 85 | const base64String =
|
---|
| 86 | "HISTFAAACGB42j1WQY4cuRGks7KzWWwOh1NTGo1GEmzBWCx0EAxjsdiTsdiTD4ZPfoa/4R/4o/7BOiKSrWnNVBWLzIyMiMzWp//897mUA7/62db1D/n3999//V8umBW74POTPds7+4In2/xq722zv9huj/bRbvZH+2oPdrV3vtu//AOeP9if8Ra7H7DlhlcPePyo+w1xrrh+84uZFzd7QkyEL/ZXJPgN295jC5bsii0FN084/BXXDQH+jqPMlhn5eYf1D/beb9h7BdSfseMJGG5C94h3BRFveibyZ9x9wR1KeaebR0P8J/vVfsCbHevv7DOxPxt2/1MrLOQz3j8BH2DjhOHpA/ZfEILRWaD9bZHyb7z60X6xRxByMzxsQEJsCPlNoP/BFI849WQP/iy+cHJHqG+4veIAWcf+DQ9Y51MRBRueHlRqEbOPXqQR74Ec28Dab9pseLpqI7na/bPCPuBz0xskIIAvUqVIpQdTcr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MR6HH2SfcVnGnsYbTfPiENP316K8Dr8+K4hpIgdlHBUdgox3jBSk6K0YP9qMBzZzRX0CQgwTYPXBw1IHCQDLeI1kDG/0E0nqOA5+O8EA+XhFytKO1E5MJlZ4dvNY5zzpeHFkhH9K8sS/npFjIZZ8aM4e/NGjUx/BjvCHA0QnkBTHwFqGO2Y+jw24T0rNF/oT3/Zx06P8BChhtKw==";
|
---|
| 87 | // when
|
---|
| 88 | histogram = decodeFromCompressedBase64(base64String, 32, true);
|
---|
| 89 | // then
|
---|
| 90 | //console.log(histogram);
|
---|
| 91 | expect(histogram.totalCount).toBe(10000);
|
---|
| 92 | });
|
---|
| 93 |
|
---|
| 94 | it("should decode and decompress a big base64 string to a wasm packed histogram", () => {
|
---|
| 95 | // given
|
---|
| 96 | const base64String =
|
---|
| 97 | "HISTFAAACGB42j1WQY4cuRGks7KzWWwOh1NTGo1GEmzBWCx0EAxjsdiTsdiTD4ZPfoa/4R/4o/7BOiKSrWnNVBWLzIyMiMzWp//897mUA7/62db1D/n3999//V8umBW74POTPds7+4In2/xq722zv9huj/bRbvZH+2oPdrV3vtu//AOeP9if8Ra7H7DlhlcPePyo+w1xrrh+84uZFzd7QkyEL/ZXJPgN295jC5bsii0FN084/BXXDQH+jqPMlhn5eYf1D/beb9h7BdSfseMJGG5C94h3BRFveibyZ9x9wR1KeaebR0P8J/vVfsCbHevv7DOxPxt2/1MrLOQz3j8BH2DjhOHpA/ZfEILRWaD9bZHyb7z60X6xRxByMzxsQEJsCPlNoP/BFI849WQP/iy+cHJHqG+4veIAWcf+DQ9Y51MRBRueHlRqEbOPXqQR74Ec28Dab9pseLpqI7na/bPCPuBz0xskIIAvUqVIpQdTcr7/Afje68RHpPwsBrXnUYE3UVy0AYubljZTggshU+gdlTHej6iyJEfXuOb+B51wcXdbzD/yaFkQNn+fXnHBY7In5Sgi4wb34IYciy83hbxSG/pJFipa+VnByeJXFMPD0pQMoUTc+i3BExV+bgKa98WYHqk2GnaH+bPg3Xl8X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Ux/BjvCHA0QnkBTHwFqGO2Y+jw24T0rNF/oT3/Zx06P8BChhtKw==";
|
---|
| 98 | // when
|
---|
| 99 | histogram = decodeFromCompressedBase64(base64String, "packed", true);
|
---|
| 100 | // then
|
---|
| 101 | expect(histogram.totalCount).toBe(10000);
|
---|
| 102 | });
|
---|
| 103 |
|
---|
| 104 | it("should encode and decode an histogram", () => {
|
---|
| 105 | // given
|
---|
| 106 | histogram = WasmHistogram.build();
|
---|
| 107 | histogram.recordValue(32415482);
|
---|
| 108 | // when
|
---|
| 109 | const b64 = encodeIntoCompressedBase64(histogram);
|
---|
| 110 | // then
|
---|
| 111 | const decodedHistogram = decodeFromCompressedBase64(b64);
|
---|
| 112 | expect(decodedHistogram.getValueAtPercentile(50)).toBe(
|
---|
| 113 | histogram.getValueAtPercentile(50)
|
---|
| 114 | );
|
---|
| 115 | });
|
---|
| 116 | });
|
---|