Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assembly/__tests__/HistogramCountsKernels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function checkEstablishTrackingValues<T, U>(h: Histogram<T, U>): void {
expect<u64>(h.totalCount).equal(total);
if (maxIndex >= 0) {
expect<u64>(h.maxValue).equal(
h.highestEquivalentValue(h.valueFromIndex(maxIndex)) + h.unitMagnitudeMask
h.highestEquivalentValue(h.valueFromIndex(maxIndex)) | h.unitMagnitudeMask
);
} else {
expect<u64>(h.maxValue).equal(0);
Expand Down
20 changes: 10 additions & 10 deletions assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,53 +474,53 @@ export function addHistogram8to8(h: Histogram8, other: Histogram8): void { h.add
export function addHistogram16to8(h: Histogram8, other: Histogram16): void { h.addHistogram16(other); }
export function addHistogram32to8(h: Histogram8, other: Histogram32): void { h.addHistogram32(other); }
export function addHistogram64to8(h: Histogram8, other: Histogram64): void { h.addHistogram64(other); }
export function addPackedHistogramto8(h: Histogram8, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogramPackedto8(h: Histogram8, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogram8to16(h: Histogram16, other: Histogram8): void { h.addHistogram8(other); }
export function addHistogram16to16(h: Histogram16, other: Histogram16): void { h.addHistogram16(other); }
export function addHistogram32to16(h: Histogram16, other: Histogram32): void { h.addHistogram32(other); }
export function addHistogram64to16(h: Histogram16, other: Histogram64): void { h.addHistogram64(other); }
export function addPackedHistogramto16(h: Histogram16, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogramPackedto16(h: Histogram16, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogram8to32(h: Histogram32, other: Histogram8): void { h.addHistogram8(other); }
export function addHistogram16to32(h: Histogram32, other: Histogram16): void { h.addHistogram16(other); }
export function addHistogram32to32(h: Histogram32, other: Histogram32): void { h.addHistogram32(other); }
export function addHistogram64to32(h: Histogram32, other: Histogram64): void { h.addHistogram64(other); }
export function addPackedHistogramto32(h: Histogram32, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogramPackedto32(h: Histogram32, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogram8to64(h: Histogram64, other: Histogram8): void { h.addHistogram8(other); }
export function addHistogram16to64(h: Histogram64, other: Histogram16): void { h.addHistogram16(other); }
export function addHistogram32to64(h: Histogram64, other: Histogram32): void { h.addHistogram32(other); }
export function addHistogram64to64(h: Histogram64, other: Histogram64): void { h.addHistogram64(other); }
export function addPackedHistogramto64(h: Histogram64, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogramPackedto64(h: Histogram64, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogram8toPacked(h: PackedHistogram, other: Histogram8): void { h.addHistogram8(other); }
export function addHistogram16toPacked(h: PackedHistogram, other: Histogram16): void { h.addHistogram16(other); }
export function addHistogram32toPacked(h: PackedHistogram, other: Histogram32): void { h.addHistogram32(other); }
export function addHistogram64toPacked(h: PackedHistogram, other: Histogram64): void { h.addHistogram64(other); }
export function addPackedHistogramtoPacked(h: PackedHistogram, other: PackedHistogram): void { h.addPackedHistogram(other); }
export function addHistogramPackedtoPacked(h: PackedHistogram, other: PackedHistogram): void { h.addPackedHistogram(other); }

export function subtractHistogram8from8(h: Histogram8, other: Histogram8): void { h.subtractHistogram8(other); }
export function subtractHistogram16from8(h: Histogram8, other: Histogram16): void { h.subtractHistogram16(other); }
export function subtractHistogram32from8(h: Histogram8, other: Histogram32): void { h.subtractHistogram32(other); }
export function subtractHistogram64from8(h: Histogram8, other: Histogram64): void { h.subtractHistogram64(other); }
export function subtractPackedHistogramfrom8(h: Histogram8, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogramPackedfrom8(h: Histogram8, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogram8from16(h: Histogram16, other: Histogram8): void { h.subtractHistogram8(other); }
export function subtractHistogram16from16(h: Histogram16, other: Histogram16): void { h.subtractHistogram16(other); }
export function subtractHistogram32from16(h: Histogram16, other: Histogram32): void { h.subtractHistogram32(other); }
export function subtractHistogram64from16(h: Histogram16, other: Histogram64): void { h.subtractHistogram64(other); }
export function subtractPackedHistogramfrom16(h: Histogram16, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogramPackedfrom16(h: Histogram16, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogram8from32(h: Histogram32, other: Histogram8): void { h.subtractHistogram8(other); }
export function subtractHistogram16from32(h: Histogram32, other: Histogram16): void { h.subtractHistogram16(other); }
export function subtractHistogram32from32(h: Histogram32, other: Histogram32): void { h.subtractHistogram32(other); }
export function subtractHistogram64from32(h: Histogram32, other: Histogram64): void { h.subtractHistogram64(other); }
export function subtractPackedHistogramfrom32(h: Histogram32, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogramPackedfrom32(h: Histogram32, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogram8from64(h: Histogram64, other: Histogram8): void { h.subtractHistogram8(other); }
export function subtractHistogram16from64(h: Histogram64, other: Histogram16): void { h.subtractHistogram16(other); }
export function subtractHistogram32from64(h: Histogram64, other: Histogram32): void { h.subtractHistogram32(other); }
export function subtractHistogram64from64(h: Histogram64, other: Histogram64): void { h.subtractHistogram64(other); }
export function subtractPackedHistogramfrom64(h: Histogram64, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogramPackedfrom64(h: Histogram64, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogram8fromPacked(h: PackedHistogram, other: Histogram8): void { h.subtractHistogram8(other); }
export function subtractHistogram16fromPacked(h: PackedHistogram, other: Histogram16): void { h.subtractHistogram16(other); }
export function subtractHistogram32fromPacked(h: PackedHistogram, other: Histogram32): void { h.subtractHistogram32(other); }
export function subtractHistogram64fromPacked(h: PackedHistogram, other: Histogram64): void { h.subtractHistogram64(other); }
export function subtractPackedHistogramfromPacked(h: PackedHistogram, other: PackedHistogram): void { h.subtractPackedHistogram(other); }
export function subtractHistogramPackedfromPacked(h: PackedHistogram, other: PackedHistogram): void { h.subtractPackedHistogram(other); }

export function addWhileCorrectingForCoordinatedOmission8(h: Histogram8, other: Histogram8, expectedIntervalBetweenValueSamples: f64): void { h.addWhileCorrectingForCoordinatedOmission(other, expectedIntervalBetweenValueSamples); }
export function addWhileCorrectingForCoordinatedOmission16(h: Histogram16, other: Histogram16, expectedIntervalBetweenValueSamples: f64): void { h.addWhileCorrectingForCoordinatedOmission(other, expectedIntervalBetweenValueSamples); }
Expand Down
34 changes: 34 additions & 0 deletions src/Histogram.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,40 @@ describe("Histogram add & substract", () => {
expect(histogram.summary).toStrictEqual(before);
});

const wasmBucketSizes = [8, 16, 32, 64, "packed"] as const;
wasmBucketSizes.forEach((thisSize) => {
wasmBucketSizes.forEach((otherSize) => {
it(`should add and subtract a WASM ${otherSize} histogram to/from a WASM ${thisSize} histogram`, () => {
// given
const histogram = build({
bitBucketSize: thisSize,
useWebAssembly: true,
numberOfSignificantValueDigits: 3,
});
const histogram2 = build({
bitBucketSize: otherSize,
useWebAssembly: true,
numberOfSignificantValueDigits: 3,
});
histogram.recordValueWithCount(100, 2);
histogram2.recordValueWithCount(100, 1);
histogram2.recordValueWithCount(42000, 1);
const before = histogram.summary;
// when
histogram.add(histogram2);
// then
expect(histogram.totalCount).toBe(4);
expect(histogram.maxValue).toBeGreaterThanOrEqual(42000);
// when
histogram.subtract(histogram2);
// then
expect(histogram.summary).toStrictEqual(before);
histogram.destroy();
histogram2.destroy();
});
});
});

it("should update percentiles when another histogram of same characteristics is substracted", () => {
// given
const histogram = build({ numberOfSignificantValueDigits: 3 });
Expand Down
Loading