-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: when an element is destroyed, its child elements are not destroyed (#1817) * fix: when an element is destroyed, its child elements are not destroyed * chore: add changeset * Version Packages (#1818) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
fe4b158
commit d09378b
Showing
102 changed files
with
649 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import * as lil from 'lil-gui'; | ||
import { type Canvas } from '@antv/g'; | ||
import * as tinybench from 'tinybench'; | ||
|
||
export async function canvasApi(context: { canvas: Canvas; gui: lil.GUI }) { | ||
const { canvas } = context; | ||
console.log(canvas); | ||
|
||
await canvas.ready; | ||
|
||
// benchmark | ||
// ---------- | ||
const bench = new tinybench.Bench({ name: 'canvas benchmark', time: 100 }); | ||
|
||
const canvasContext = canvas | ||
.getContextService() | ||
.getContext() as CanvasRenderingContext2D; | ||
const offscreenCanvas = new OffscreenCanvas( | ||
canvas.getConfig().width, | ||
canvas.getConfig().height, | ||
).getContext('2d'); | ||
const props = { | ||
fillStyle: '#000', | ||
strokeStyle: '#000', | ||
globalAlpha: 1, | ||
globalCompositeOperation: 'source-over', | ||
filter: 'none', | ||
}; | ||
const propsKeys = Object.keys(props); | ||
|
||
bench.add('get object props', () => { | ||
propsKeys.forEach((key) => { | ||
props[key]; | ||
}); | ||
}); | ||
bench.add('set object props', () => { | ||
propsKeys.forEach((key) => { | ||
props[key] = props[key]; | ||
}); | ||
}); | ||
|
||
propsKeys.forEach((key) => { | ||
bench.add(`get canvas context props - ${key}`, async () => { | ||
canvasContext[key]; | ||
}); | ||
bench.add(`set canvas context props - ${key}`, async () => { | ||
canvasContext[key] = canvasContext[key]; | ||
}); | ||
}); | ||
bench.add('canvas context save() & restore()', async () => { | ||
canvasContext.save(); | ||
canvasContext.restore(); | ||
}); | ||
|
||
propsKeys.forEach((key) => { | ||
bench.add(`get offscreenCanvas context props - ${key}`, async () => { | ||
offscreenCanvas[key]; | ||
}); | ||
bench.add(`set offscreenCanvas context props - ${key}`, async () => { | ||
offscreenCanvas[key] = canvasContext[key]; | ||
}); | ||
}); | ||
bench.add('canvas offscreenCanvas save() & restore()', async () => { | ||
offscreenCanvas.save(); | ||
offscreenCanvas.restore(); | ||
}); | ||
|
||
await bench.run(); | ||
|
||
console.log(bench.name); | ||
console.table(bench.table()); | ||
console.log(bench.results); | ||
console.log(bench.tasks); | ||
|
||
// ---------- | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import * as lil from 'lil-gui'; | ||
import { type Canvas } from '@antv/g'; | ||
import * as tinybench from 'tinybench'; | ||
import { isNil } from '@antv/util'; | ||
|
||
export async function javascript(context: { canvas: Canvas; gui: lil.GUI }) { | ||
const { canvas } = context; | ||
console.log(canvas); | ||
|
||
await canvas.ready; | ||
|
||
// benchmark | ||
// ---------- | ||
const bench = new tinybench.Bench({ name: 'canvas benchmark', time: 1e2 }); | ||
const array = [ | ||
'stroke', | ||
'shadowType', | ||
'shadowOffsetX', | ||
'shadowOffsetY', | ||
'shadowBlur', | ||
'lineWidth', | ||
'increasedLineWidthForHitTesting', | ||
'lineJoin', | ||
'lineCap', | ||
'dx', | ||
'dy', | ||
'filter', | ||
'textPathStartOffset', | ||
'transformOrigin', | ||
'cx', | ||
'cy', | ||
'cz', | ||
'r', | ||
'rx', | ||
'ry', | ||
'x', | ||
'y', | ||
'z', | ||
'width', | ||
'height', | ||
'radius', | ||
'x1', | ||
'y1', | ||
'z1', | ||
'x2', | ||
'y2', | ||
'z2', | ||
'd', | ||
'points', | ||
'text', | ||
'textTransform', | ||
'font', | ||
'fontSize', | ||
'fontFamily', | ||
'fontStyle', | ||
'fontWeight', | ||
'fontVariant', | ||
'lineHeight', | ||
'letterSpacing', | ||
'miterLimit', | ||
'wordWrap', | ||
'wordWrapWidth', | ||
'maxLines', | ||
'textOverflow', | ||
'leading', | ||
'textBaseline', | ||
'textAlign', | ||
'markerStartOffset', | ||
'markerEndOffset', | ||
]; | ||
const object = { stroke: '', fill: '' }; | ||
|
||
// bench.add('for', async () => { | ||
// for (let i = 0; i < array.length; i++) { | ||
// if (array[i] in object) { | ||
// break; | ||
// } | ||
// } | ||
// }); | ||
// bench.add('for & typeof', async () => { | ||
// for (let i = 0; i < array.length; i++) { | ||
// if (typeof object[array[i]] !== 'undefined') { | ||
// break; | ||
// } | ||
// } | ||
// }); | ||
// bench.add('object.keys', async () => { | ||
// Object.keys(object).some((name) => array.includes(name)); | ||
// }); | ||
// bench.add('array.some', async () => { | ||
// array.some((name) => name in object); | ||
// }); | ||
|
||
// const value = ''; | ||
// bench.add('typeof - isNil', async () => { | ||
// !(typeof value === 'undefined' || value === null); | ||
// }); | ||
// bench.add('@antv/util - isNil', async () => { | ||
// !isNil(value); | ||
// }); | ||
|
||
const stringKey = 'fill'; | ||
const objectKey = { a: 1 }; | ||
const map = new Map(); | ||
bench.add('Map set - stringKey', async () => { | ||
map.set(stringKey, 1); | ||
}); | ||
bench.add('Map set - objectKey', async () => { | ||
map.set(objectKey, 1); | ||
}); | ||
|
||
await bench.run(); | ||
|
||
console.log(bench.name); | ||
console.table(bench.table()); | ||
console.log(bench.results); | ||
console.log(bench.tasks); | ||
|
||
// ---------- | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.