Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lite load perf ci #8222

Merged
merged 12 commits into from
Jul 11, 2024
5 changes: 5 additions & 0 deletions .changeset/wet-seas-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gradio/tootils": minor
---

feat:Lite load perf ci
14 changes: 10 additions & 4 deletions .github/workflows/test-functional.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: "test / functional"

on:
workflow_run:
workflows: ["trigger"]
types:
- requested
# workflow_run:
# workflows: ["trigger"]
# types:
# - requested
pull_request: {}

permissions:
statuses: write
Expand Down Expand Up @@ -79,6 +80,11 @@ jobs:
run: |
. venv/bin/activate
pnpm --filter @gradio/app test:browser:lite
- name: Get the performance result
run: |
export LITE_APP_LOAD_TIME=$(jq -r '.app_load_time' .lite-perf.json)
echo "LITE_APP_LOAD_TIME=$LITE_APP_LOAD_TIME" >> $GITHUB_ENV
cat .lite-perf.json # For debugging
- name: do check
if: always()
uses: "gradio-app/github/actions/commit-status@main"
Expand Down
28 changes: 28 additions & 0 deletions js/tootils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test as base, type Locator, type Page } from "@playwright/test";
import { spy } from "tinyspy";
import { performance } from "node:perf_hooks";
import url from "url";
import path from "path";
import fsPromises from "fs/promises";
Expand Down Expand Up @@ -47,7 +48,34 @@ const test_lite = base.extend<{ setup: void }>({
}
if (shared_page_for_lite.url() !== lite_url) {
await shared_page_for_lite.goto(lite_url);

performance.mark("opened");

testInfo.setTimeout(600000); // Lite takes a long time to initialize.

// Measure the time taken for the app to load.
shared_page_for_lite
.waitForSelector('css=[id^="component-"]', { state: "visible" })
.then(() => {
performance.mark("app-loaded");
const app_load_perf = performance.measure(
"app-load",
"opened",
"app-loaded"
);
const app_load_time = app_load_perf.duration;

const perf_file_content = JSON.stringify({ app_load_time }, null, 2);

fsPromises
.writeFile(
path.resolve(ROOT_DIR, `./.lite-perf.json`),
perf_file_content
)
.catch((err) => {
console.error("Failed to write the performance data.", err);
});
});
}
await use(shared_page_for_lite);
},
Expand Down
Loading