Skip to content

Commit f4ca018

Browse files
authored
Merge pull request #1746 from VisActor/test/memory
test: add memory test
2 parents 5fca1e1 + 3b44ba3 commit f4ca018

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/vrender/__tests__/browser/src/pages/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export const pages = [
1515
name: '性能测试',
1616
path: 'performance-test'
1717
},
18+
{
19+
name: '内存',
20+
path: 'memory'
21+
},
1822
{
1923
name: '按需加载',
2024
path: 'anxu-picker'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { createStage, createRect, IGraphic } from '@visactor/vrender';
2+
import { roughModule } from '@visactor/vrender-kits';
3+
import { addShapesToStage, colorPools } from '../utils';
4+
5+
// container.load(roughModule);
6+
export const page = () => {
7+
let stage: any;
8+
function run() {
9+
stage && stage.release();
10+
const graphics: IGraphic[] = [];
11+
for (let i = 0; i < 10000; i++) {
12+
graphics.push(createRect({ x: 100, y: 100, width: 100, height: 100, fill: 'red' }));
13+
}
14+
15+
stage = createStage({
16+
canvas: 'main',
17+
canvasControled: false,
18+
autoRender: true,
19+
autoRefresh: true
20+
});
21+
graphics.forEach(g => {
22+
stage.defaultLayer.add(g);
23+
});
24+
}
25+
const button = document.createElement('button');
26+
button.innerHTML = 'run';
27+
button.onclick = () => {
28+
for (let i = 0; i < 300; i++) {
29+
run();
30+
}
31+
};
32+
document.body.appendChild(button);
33+
};

0 commit comments

Comments
 (0)