task-benchmark.spec.ts 1.1 KB

1234567891011121314151617181920
  1. import { test, expect } from "@playwright/test"
  2. import { writeFileSync } from "node:fs"
  3. test("production workbench task admission benchmark", async ({ page }) => {
  4. const samples: number[] = []
  5. await page.goto("/e2e/paas/index.html?ux")
  6. await page.getByLabel("API Key", { exact: true }).fill("synthetic")
  7. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  8. for (let i = 0; i < 5; i++) {
  9. await page.getByRole("textbox", { name: "消息", exact: true }).fill(`基准任务 ${i}`)
  10. const start = performance.now()
  11. await page.getByRole("button", { name: "发送消息", exact: true }).click()
  12. await expect(page.getByRole("button", { name: "暂停", exact: true })).toBeVisible()
  13. samples.push(performance.now() - start)
  14. await page.locator(".paas-topbar-chat-actions").getByRole("button", { name: "新会话", exact: true }).click()
  15. }
  16. writeFileSync(
  17. process.env.BENCH_OUTPUT || "/private/tmp/lambda-task-baseline.json",
  18. JSON.stringify({ samples, mean: samples.reduce((a, b) => a + b, 0) / samples.length }),
  19. )
  20. })