resourceMetricsStats.test.ts 574 B

1234567891011121314151617
  1. import { describe, expect, it } from "vitest";
  2. import { appendBoundedSamples, computeAggregateStats } from "../src/main/resourceMetricsStats.js";
  3. describe("resourceMetricsStats", () => {
  4. it("computes mean peak p95", () => {
  5. const stats = computeAggregateStats([10, 20, 30, 40, 50]);
  6. expect(stats.sample_count).toBe(5);
  7. expect(stats.mean).toBe(30);
  8. expect(stats.peak).toBe(50);
  9. expect(stats.p95).toBe(50);
  10. });
  11. it("bounds sample array", () => {
  12. const next = appendBoundedSamples([1, 2, 3], 4, 3);
  13. expect(next).toEqual([2, 3, 4]);
  14. });
  15. });