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

test: config perf test env, add perf test case and report #6194

Merged
merged 3 commits into from
Aug 21, 2024
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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"publish": "pnpm publish -r --publish-branch v5",
"site": "pnpm -r --stream --filter=./packages/site run dev",
"version": "changeset version && turbo version",
"watch": "pnpm -r --stream --filter=!./site run start"
"watch": "pnpm -r --stream --filter=!./site run start",
"perf": "npm run perf"
},
"commitlint": {
"extends": [
Expand All @@ -23,6 +24,9 @@
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md}": [
"prettier --write"
]
},
"devDependencies": {
Expand All @@ -47,6 +51,7 @@
"eslint": "^8.57.0",
"eslint-plugin-jsdoc": "^46.10.1",
"husky": "^8.0.3",
"iperf": "^0.1.0-beta.7",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^23.2.0",
Expand Down
229 changes: 229 additions & 0 deletions packages/g6/__tests__/perf-report/9821ed36_2024-08-19_16:33:46.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"version": "1.0",
"device": {
"os": {
"arch": "arm64",
"distro": "macOS",
"serial": "9821ed36011eee5abf6c71d6fc2c03fb4bf4655e674c56b7f50e2560cb6e924a"
},
"cpu": {
"manufacturer": "Apple",
"brand": "M1 Pro",
"speed": 2.4,
"cores": 10
},
"memory": {
"total": 16384,
"free": 58.015625
},
"gpu": {
"vendor": "Apple",
"model": "Apple M1 Pro",
"cores": "16"
}
},
"repo": "ab97b6a84c9b1ac7f599e34568714376278583f0",
"client": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
"reports": {
"dataDiff1000": {
"time": [
{
"min": 1.8999999999068677,
"max": 9,
"median": 2.8999999999068677,
"avg": 7.25,
"variance": 32.390000000039585,
"reliable": false,
"memory": 30.162158966064453,
"key": "data diff"
}
],
"status": "passed"
},
"dataDiff10000": {
"time": [
{
"min": 12.199999999953434,
"max": 7.900000000139698,
"median": 6.7999999998137355,
"avg": 6.324999999982538,
"variance": 1.35437500005326,
"reliable": true,
"memory": 62.23182191848755,
"key": "data diff"
}
],
"status": "passed"
},
"dataDiff100000": {
"time": [
{
"min": 29.300000000046566,
"max": 67.10000000009313,
"median": 36.10000000009313,
"avg": 35.64999999999418,
"variance": 16.877500000362634,
"reliable": true,
"memory": 369.5241134643555,
"key": "data diff"
}
],
"status": "passed"
},
"dataDiff5000": {
"time": [
{
"min": 2.6000000000931323,
"max": 7.599999999860302,
"median": 3,
"avg": 3.5125000000116415,
"variance": 2.188593750007858,
"reliable": false,
"memory": 585.6023946762085,
"key": "data diff"
}
],
"status": "passed"
},
"dataDiff50000": {
"time": [
{
"min": 13.699999999953434,
"max": 55.199999999953434,
"median": 17.600000000093132,
"avg": 22.66250000000582,
"variance": 132.55484375006213,
"reliable": true,
"memory": 722.3826655387878,
"key": "data diff"
}
],
"status": "passed"
},
"elementDrawing100": {
"time": [
{
"min": 10.5,
"max": 9.5,
"median": 15.800000000046566,
"avg": 16.57500000006985,
"variance": 163.99937499927708,
"reliable": true,
"memory": 826.2329563140869,
"key": "element drawing"
},
{
"min": 10.399999999906868,
"max": 8.5,
"median": 7.7999999998137355,
"avg": 8.450000000011642,
"variance": 4.637500000128056,
"reliable": true,
"memory": 826.4959269523621,
"key": "grid layout"
}
],
"status": "passed"
},
"elementDrawing1000": {
"time": [
{
"min": 100.79999999981374,
"max": 84.69999999995343,
"median": 117.39999999990687,
"avg": 100.46250000002328,
"variance": 255.6148437497992,
"reliable": true,
"memory": 830.0374026298523,
"key": "element drawing"
},
{
"min": 59.5999999998603,
"max": 77.29999999981374,
"median": 67.30000000004657,
"avg": 66.9375000000291,
"variance": 12.824843750080472,
"reliable": true,
"memory": 829.3771424293518,
"key": "grid layout"
}
],
"status": "passed"
},
"elementDrawing10000": {
"time": [
{
"min": 416.30000000004657,
"max": 649.0999999998603,
"median": 596.5,
"avg": 593.7874999999185,
"variance": 450.70359375090015,
"reliable": true,
"memory": 1099.1369720458983,
"key": "element drawing"
},
{
"min": 352.60000000009313,
"max": 377.70000000018626,
"median": 366.5,
"avg": 366.3125,
"variance": 5.318593750001164,
"reliable": true,
"memory": 1131.638009262085,
"key": "grid layout"
}
],
"status": "passed"
},
"elementDrawing500": {
"time": [
{
"min": 126.39999999990687,
"max": 49.60000000009313,
"median": 42.300000000046566,
"avg": 40.97500000000582,
"variance": 7.959374999943247,
"reliable": true,
"memory": 1362.0711398124695,
"key": "element drawing"
},
{
"min": 29.300000000046566,
"max": 42.89999999990687,
"median": 34.39999999990687,
"avg": 34.299999999959255,
"variance": 5.03999999981257,
"reliable": true,
"memory": 1362.0711398124695,
"key": "grid layout"
}
],
"status": "passed"
},
"elementDrawing5000": {
"time": [
{
"min": 381.19999999995343,
"max": 548.1999999999534,
"median": 408.80000000004657,
"avg": 428.375,
"variance": 1986.7618749965764,
"reliable": true,
"memory": 1483.8886072158814,
"key": "element drawing"
},
{
"min": 208.19999999995343,
"max": 291.80000000004657,
"median": 264.60000000009313,
"avg": 262.70000000001164,
"variance": 166.63749999852735,
"reliable": true,
"memory": 1479.9850234985352,
"key": "grid layout"
}
],
"status": "passed"
}
}
}
33 changes: 33 additions & 0 deletions packages/g6/__tests__/perf/data.perf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Graph } from '@antv/g6';
import type { Test } from 'iperf';

const DataTestWrapper = (count: number): Test => {
return async ({ container, perf }) => {
const graph = new Graph({
container,
data: {
nodes: Array(count)
.fill(0)
.map((_, i) => ({ id: `${i}`, style: { x: 50, y: 50 } })),
},
});
await perf.evaluate('data diff', async () => {
// @ts-expect-error private method invoke
await graph.prepare();
// @ts-expect-error context is private property
const context = graph.context;
// @ts-expect-error private method invoke
context.element.computeChangesAndDrawData({});
});
};
};

export const dataDiff1000: Test = DataTestWrapper(1000);

export const dataDiff5000: Test = DataTestWrapper(5000);

export const dataDiff10000: Test = DataTestWrapper(10000);

export const dataDiff50000: Test = DataTestWrapper(50000);

export const dataDiff100000: Test = DataTestWrapper(100000);
37 changes: 37 additions & 0 deletions packages/g6/__tests__/perf/draw.perf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Graph } from '@antv/g6';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面可以单开一个 perf 目录单独存放。

import type { Test } from 'iperf';

const ElementTestWrapper = (count: number): Test => {
return async ({ container, perf }) => {
const graph = new Graph({
container,
animation: false, // be sure to close the animation
data: {
nodes: Array(count)
.fill(0)
.map((_, i) => ({ id: `${i}`, style: { x: 50, y: 50 } })),
},
layout: {
type: 'grid',
},
});

await perf.evaluate('element drawing', async () => {
await graph.draw();
});

await perf.evaluate('grid layout', async () => {
await graph.layout();
});
};
};

export const elementDrawing100: Test = ElementTestWrapper(100);

export const elementDrawing500: Test = ElementTestWrapper(500);

export const elementDrawing1000: Test = ElementTestWrapper(1000);

export const elementDrawing5000: Test = ElementTestWrapper(5000);

export const elementDrawing10000: Test = ElementTestWrapper(10000);
15 changes: 15 additions & 0 deletions packages/g6/perf.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'iperf';
import path from 'path';

export default defineConfig({
perf: {
report: {
dir: './__tests__/perf-report',
},
},
resolve: {
alias: {
'@antv/g6': path.resolve(__dirname, './src'),
},
},
});
Loading