MCPcopy
hub / github.com/excalidraw/excalidraw / makeElements

Function makeElements

packages/excalidraw/element/sortElements.test.ts:370–395  ·  view source on GitHub ↗
(iterations: number)

Source from the content-addressed store, hash-verified

368 // should take around <100ms for 10K iterations (@dwelle's PC 22-05-25)
369 it.skip("normalizeElementsOrder() perf", () => {
370 const makeElements = (iterations: number) => {
371 const elements: ExcalidrawElement[] = [];
372 while (iterations--) {
373 const container = API.createElement({
374 type: "rectangle",
375 boundElements: [],
376 groupIds: ["B", "A"],
377 });
378 const boundText = API.createElement({
379 type: "text",
380 containerId: container.id,
381 groupIds: ["A"],
382 });
383 const otherElement = API.createElement({
384 type: "rectangle",
385 boundElements: [],
386 groupIds: ["C", "A"],
387 });
388 mutateElement(container, {
389 boundElements: [{ type: "text", id: boundText.id }],
390 });
391
392 elements.push(boundText, otherElement, container);
393 }
394 return elements;
395 };
396
397 const elements = makeElements(10000);
398 const t0 = Date.now();

Callers 1

Calls 3

mutateElementFunction · 0.90
createElementMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…