[6a3a178] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | const HistogramLogWriter_1 = require("./HistogramLogWriter");
|
---|
| 4 | const Int32Histogram_1 = require("./Int32Histogram");
|
---|
| 5 | describe("Histogram Log Writer", () => {
|
---|
| 6 | let buffer;
|
---|
| 7 | let writer;
|
---|
| 8 | let histogram;
|
---|
| 9 | beforeEach(() => {
|
---|
| 10 | buffer = "";
|
---|
| 11 | writer = new HistogramLogWriter_1.default((content) => {
|
---|
| 12 | buffer += content;
|
---|
| 13 | });
|
---|
| 14 | histogram = new Int32Histogram_1.default(1, Number.MAX_SAFE_INTEGER, 3);
|
---|
| 15 | });
|
---|
| 16 | it("should write a line with start time, duration, max value, and a base64 encoded histogram", () => {
|
---|
| 17 | // given
|
---|
| 18 | histogram.recordValue(123000);
|
---|
| 19 | // when
|
---|
| 20 | writer.outputIntervalHistogram(histogram, 1000, 1042);
|
---|
| 21 | // then
|
---|
| 22 | expect(buffer).toMatch(/^1000.000,42.000,123.000,HISTFAA/);
|
---|
| 23 | });
|
---|
| 24 | it("should write start time, duration and max value using 3 digits", () => {
|
---|
| 25 | // given
|
---|
| 26 | histogram.recordValue(123001);
|
---|
| 27 | // when
|
---|
| 28 | writer.outputIntervalHistogram(histogram, 1000.0120001, 1042.013001);
|
---|
| 29 | // then
|
---|
| 30 | expect(buffer).toMatch(/^1000.012,42.001,123.001,HISTFAA/);
|
---|
| 31 | });
|
---|
| 32 | it("should write a line starting with histogram tag", () => {
|
---|
| 33 | // given
|
---|
| 34 | histogram.tag = "TAG";
|
---|
| 35 | histogram.recordValue(123000);
|
---|
| 36 | // when
|
---|
| 37 | writer.outputIntervalHistogram(histogram, 1000, 1042);
|
---|
| 38 | // then
|
---|
| 39 | expect(buffer).toContain("Tag=TAG,1000.000,42.000,123.000,HISTFAA");
|
---|
| 40 | });
|
---|
| 41 | it("should write a histogram's start time in sec using basetime", () => {
|
---|
| 42 | // given
|
---|
| 43 | histogram.startTimeStampMsec = 1234001;
|
---|
| 44 | histogram.endTimeStampMsec = 1235001;
|
---|
| 45 | writer.baseTime = 1000000;
|
---|
| 46 | histogram.recordValue(1);
|
---|
| 47 | // when
|
---|
| 48 | writer.outputIntervalHistogram(histogram);
|
---|
| 49 | // then
|
---|
| 50 | expect(buffer).toContain("234.001");
|
---|
| 51 | });
|
---|
| 52 | it("should write start time in seconds", () => {
|
---|
| 53 | // given
|
---|
| 54 | // when
|
---|
| 55 | writer.outputStartTime(1234560);
|
---|
| 56 | // then
|
---|
| 57 | expect(buffer).toContain("1234.560");
|
---|
| 58 | });
|
---|
| 59 | });
|
---|
| 60 | //# sourceMappingURL=HistogramLogWriter.spec.js.map |
---|