@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.js CHANGED
@@ -921,6 +921,7 @@ function serializeTextNode(n2, options) {
921
921
  };
922
922
  }
923
923
  function serializeElementNode(n2, options) {
924
+ const start = performance.now();
924
925
  const {
925
926
  doc,
926
927
  blockClass,
@@ -1112,6 +1113,18 @@ function serializeElementNode(n2, options) {
1112
1113
  if (customElements.get(tagName)) isCustomElement = true;
1113
1114
  } catch (e2) {
1114
1115
  }
1116
+ const took = performance.now() - start;
1117
+ if (!(tagName in window.serialization_perf_map)) {
1118
+ window.serialization_perf_map[tagName] = {
1119
+ avg: 0,
1120
+ times: []
1121
+ };
1122
+ }
1123
+ window.serialization_perf_map[tagName].times.push(took);
1124
+ if (window.serialization_perf_map[tagName].times.length > 1e3) {
1125
+ window.serialization_perf_map[tagName].times.shift();
1126
+ }
1127
+ 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;
1115
1128
  return {
1116
1129
  type: NodeType$3.Element,
1117
1130
  tagName,
@@ -1291,7 +1304,9 @@ function serializeNodeWithId(n2, options) {
1291
1304
  }
1292
1305
  let shadowRootEl = null;
1293
1306
  if (isElement(n2) && (shadowRootEl = index$1.shadowRoot(n2))) {
1294
- for (const childN of Array.from(index$1.childNodes(shadowRootEl))) {
1307
+ const childNodes2 = index$1.childNodes(shadowRootEl);
1308
+ for (let i2 = 0; i2 < childNodes2.length; i2++) {
1309
+ const childN = childNodes2[i2];
1295
1310
  const serializedChildNode = serializeNodeWithId(
1296
1311
  childN,
1297
1312
  bypassOptions
@@ -9391,12 +9406,36 @@ class MutationBuffer {
9391
9406
  __publicField(this, "canvasManager");
9392
9407
  __publicField(this, "processedNodeManager");
9393
9408
  __publicField(this, "unattachedDoc");
9409
+ __publicField(this, "tempPerfStore", {});
9394
9410
  __publicField(this, "processMutations", (mutations) => {
9395
- console.time("processMutations");
9411
+ const start = performance.now();
9412
+ let uniqueTypes = [];
9396
9413
  for (const mut of mutations) {
9414
+ const mutStart = performance.now();
9397
9415
  this.processMutation(mut);
9416
+ const took = performance.now() - mutStart;
9417
+ if (!uniqueTypes.includes(mut.type)) uniqueTypes.push(mut.type);
9418
+ if (!(mut.type in this.tempPerfStore)) {
9419
+ this.tempPerfStore[mut.type] = {
9420
+ avg: 0,
9421
+ times: []
9422
+ };
9423
+ }
9424
+ this.tempPerfStore[mut.type].times.push(took);
9425
+ if (this.tempPerfStore[mut.type].times.length > 1e3) {
9426
+ this.tempPerfStore[mut.type].times.shift();
9427
+ }
9428
+ this.tempPerfStore[mut.type].avg = this.tempPerfStore[mut.type].times.reduce((a2, b) => a2 + b, 0) / this.tempPerfStore[mut.type].times.length;
9398
9429
  }
9399
- console.timeEnd("processMutations");
9430
+ console.log(
9431
+ mutations.length,
9432
+ "mutations processed in",
9433
+ performance.now() - start,
9434
+ "ms",
9435
+ "types:",
9436
+ uniqueTypes
9437
+ );
9438
+ window.temp_perf_store = this.tempPerfStore;
9400
9439
  this.emit();
9401
9440
  });
9402
9441
  __publicField(this, "emit", () => {
@@ -12248,6 +12287,7 @@ function record(options = {}) {
12248
12287
  if (!recordDOM) {
12249
12288
  return;
12250
12289
  }
12290
+ const start = performance.now();
12251
12291
  wrappedEmit(
12252
12292
  {
12253
12293
  type: EventType.Meta,
@@ -12315,6 +12355,7 @@ function record(options = {}) {
12315
12355
  document.adoptedStyleSheets,
12316
12356
  mirror.getId(document)
12317
12357
  );
12358
+ console.log("full snapshot took", performance.now() - start, "ms");
12318
12359
  };
12319
12360
  try {
12320
12361
  const handlers = [];