import { describe, expect, it } from "vitest";
import { runPerformanceBaseline } from "../../src/kdl/performanceBaseline.js";

describe("KDL performance baseline", () => {
  it("records TypedArray and batch baseline metrics", async () => {
    const result = await runPerformanceBaseline();
    const metrics = Object.fromEntries(result.metrics.map((metric) => [metric.name, metric]));

    expect(result.ok).toBe(true);
    expect(result.diagnostics).toEqual([]);
    expect(metrics.robot_init_6_axis?.totalMs).toBeLessThanOrEqual(1_000);
    expect(metrics.fk_pose7_typed_array?.averageMs).toBeLessThanOrEqual(1);
    expect(metrics.ik_planar_average?.averageMs).toBeLessThanOrEqual(10);
    expect(metrics.reachability_batch_1000).toMatchObject({
      points: 1_000,
      ok: true
    });
    expect(metrics.trajectory_10s_4ms).toMatchObject({
      ok: true
    });
    expect(metrics.trajectory_10s_4ms?.points).toBeGreaterThanOrEqual(2_500);
  });
});
