@glimt/record 0.0.20 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/record.cjs CHANGED
@@ -923,6 +923,7 @@ function serializeTextNode(n2, options) {
923
923
  };
924
924
  }
925
925
  function serializeElementNode(n2, options) {
926
+ const start = performance.now();
926
927
  const {
927
928
  doc,
928
929
  blockClass,
@@ -1114,6 +1115,18 @@ function serializeElementNode(n2, options) {
1114
1115
  if (customElements.get(tagName)) isCustomElement = true;
1115
1116
  } catch (e2) {
1116
1117
  }
1118
+ const took = performance.now() - start;
1119
+ if (!(tagName in window.serialization_perf_map)) {
1120
+ window.serialization_perf_map[tagName] = {
1121
+ avg: 0,
1122
+ times: []
1123
+ };
1124
+ }
1125
+ window.serialization_perf_map[tagName].times.push(took);
1126
+ if (window.serialization_perf_map[tagName].times.length > 1e3) {
1127
+ window.serialization_perf_map[tagName].times.shift();
1128
+ }
1129
+ window.serialization_perf_map[tagName].avg = window.serialization_perf_map[tagName].times.reduce((a2, b) => a2 + b, 0) / window.serialization_perf_map[tagName].times.length;
1117
1130
  return {
1118
1131
  type: NodeType$3.Element,
1119
1132
  tagName,
@@ -1293,7 +1306,9 @@ function serializeNodeWithId(n2, options) {
1293
1306
  }
1294
1307
  let shadowRootEl = null;
1295
1308
  if (isElement(n2) && (shadowRootEl = index$1.shadowRoot(n2))) {
1296
- for (const childN of Array.from(index$1.childNodes(shadowRootEl))) {
1309
+ const childNodes2 = index$1.childNodes(shadowRootEl);
1310
+ for (let i2 = 0; i2 < childNodes2.length; i2++) {
1311
+ const childN = childNodes2[i2];
1297
1312
  const serializedChildNode = serializeNodeWithId(
1298
1313
  childN,
1299
1314
  bypassOptions
@@ -9393,12 +9408,36 @@ class MutationBuffer {
9393
9408
  __publicField(this, "canvasManager");
9394
9409
  __publicField(this, "processedNodeManager");
9395
9410
  __publicField(this, "unattachedDoc");
9411
+ __publicField(this, "tempPerfStore", {});
9396
9412
  __publicField(this, "processMutations", (mutations) => {
9397
- console.time("processMutations");
9413
+ const start = performance.now();
9414
+ let uniqueTypes = [];
9398
9415
  for (const mut of mutations) {
9416
+ const mutStart = performance.now();
9399
9417
  this.processMutation(mut);
9418
+ const took = performance.now() - mutStart;
9419
+ if (!uniqueTypes.includes(mut.type)) uniqueTypes.push(mut.type);
9420
+ if (!(mut.type in this.tempPerfStore)) {
9421
+ this.tempPerfStore[mut.type] = {
9422
+ avg: 0,
9423
+ times: []
9424
+ };
9425
+ }
9426
+ this.tempPerfStore[mut.type].times.push(took);
9427
+ if (this.tempPerfStore[mut.type].times.length > 1e3) {
9428
+ this.tempPerfStore[mut.type].times.shift();
9429
+ }
9430
+ this.tempPerfStore[mut.type].avg = this.tempPerfStore[mut.type].times.reduce((a2, b) => a2 + b, 0) / this.tempPerfStore[mut.type].times.length;
9400
9431
  }
9401
- console.timeEnd("processMutations");
9432
+ console.log(
9433
+ mutations.length,
9434
+ "mutations processed in",
9435
+ performance.now() - start,
9436
+ "ms",
9437
+ "types:",
9438
+ uniqueTypes
9439
+ );
9440
+ window.temp_perf_store = this.tempPerfStore;
9402
9441
  this.emit();
9403
9442
  });
9404
9443
  __publicField(this, "emit", () => {
@@ -12250,6 +12289,7 @@ function record(options = {}) {
12250
12289
  if (!recordDOM) {
12251
12290
  return;
12252
12291
  }
12292
+ const start = performance.now();
12253
12293
  wrappedEmit(
12254
12294
  {
12255
12295
  type: EventType.Meta,
@@ -12317,6 +12357,7 @@ function record(options = {}) {
12317
12357
  document.adoptedStyleSheets,
12318
12358
  mirror.getId(document)
12319
12359
  );
12360
+ console.log("full snapshot took", performance.now() - start, "ms");
12320
12361
  };
12321
12362
  try {
12322
12363
  const handlers = [];