Skip to content

Commit

Permalink
Merge pull request #1746 from VisActor/test/memory
Browse files Browse the repository at this point in the history
test: add memory test
  • Loading branch information
neuqzxy authored Feb 21, 2025
2 parents 5fca1e1 + 3b44ba3 commit f4ca018
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vrender/__tests__/browser/src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const pages = [
name: '性能测试',
path: 'performance-test'
},
{
name: '内存',
path: 'memory'
},
{
name: '按需加载',
path: 'anxu-picker'
Expand Down
33 changes: 33 additions & 0 deletions packages/vrender/__tests__/browser/src/pages/memory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { createStage, createRect, IGraphic } from '@visactor/vrender';
import { roughModule } from '@visactor/vrender-kits';
import { addShapesToStage, colorPools } from '../utils';

// container.load(roughModule);
export const page = () => {
let stage: any;
function run() {
stage && stage.release();
const graphics: IGraphic[] = [];
for (let i = 0; i < 10000; i++) {
graphics.push(createRect({ x: 100, y: 100, width: 100, height: 100, fill: 'red' }));
}

stage = createStage({
canvas: 'main',
canvasControled: false,
autoRender: true,
autoRefresh: true
});
graphics.forEach(g => {
stage.defaultLayer.add(g);
});
}
const button = document.createElement('button');
button.innerHTML = 'run';
button.onclick = () => {
for (let i = 0; i < 300; i++) {
run();
}
};
document.body.appendChild(button);
};

0 comments on commit f4ca018

Please sign in to comment.