@glimt/record 0.0.21 → 0.0.23

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,19 @@ 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 (!window.serialization_perf_map) window.serialization_perf_map = {};
1120
+ if (!(tagName in window.serialization_perf_map)) {
1121
+ window.serialization_perf_map[tagName] = {
1122
+ avg: 0,
1123
+ times: []
1124
+ };
1125
+ }
1126
+ window.serialization_perf_map[tagName].times.push(took);
1127
+ if (window.serialization_perf_map[tagName].times.length > 1e3) {
1128
+ window.serialization_perf_map[tagName].times.shift();
1129
+ }
1130
+ 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
1131
  return {
1118
1132
  type: NodeType$3.Element,
1119
1133
  tagName,
@@ -1293,7 +1307,9 @@ function serializeNodeWithId(n2, options) {
1293
1307
  }
1294
1308
  let shadowRootEl = null;
1295
1309
  if (isElement(n2) && (shadowRootEl = index$1.shadowRoot(n2))) {
1296
- for (const childN of Array.from(index$1.childNodes(shadowRootEl))) {
1310
+ const childNodes2 = index$1.childNodes(shadowRootEl);
1311
+ for (let i2 = 0; i2 < childNodes2.length; i2++) {
1312
+ const childN = childNodes2[i2];
1297
1313
  const serializedChildNode = serializeNodeWithId(
1298
1314
  childN,
1299
1315
  bypassOptions
@@ -9396,10 +9412,12 @@ class MutationBuffer {
9396
9412
  __publicField(this, "tempPerfStore", {});
9397
9413
  __publicField(this, "processMutations", (mutations) => {
9398
9414
  const start = performance.now();
9415
+ let uniqueTypes = [];
9399
9416
  for (const mut of mutations) {
9400
9417
  const mutStart = performance.now();
9401
9418
  this.processMutation(mut);
9402
9419
  const took = performance.now() - mutStart;
9420
+ if (!uniqueTypes.includes(mut.type)) uniqueTypes.push(mut.type);
9403
9421
  if (!(mut.type in this.tempPerfStore)) {
9404
9422
  this.tempPerfStore[mut.type] = {
9405
9423
  avg: 0,
@@ -9416,7 +9434,9 @@ class MutationBuffer {
9416
9434
  mutations.length,
9417
9435
  "mutations processed in",
9418
9436
  performance.now() - start,
9419
- "ms"
9437
+ "ms",
9438
+ "types:",
9439
+ uniqueTypes
9420
9440
  );
9421
9441
  window.temp_perf_store = this.tempPerfStore;
9422
9442
  this.emit();
@@ -12270,6 +12290,7 @@ function record(options = {}) {
12270
12290
  if (!recordDOM) {
12271
12291
  return;
12272
12292
  }
12293
+ const start = performance.now();
12273
12294
  wrappedEmit(
12274
12295
  {
12275
12296
  type: EventType.Meta,
@@ -12337,6 +12358,7 @@ function record(options = {}) {
12337
12358
  document.adoptedStyleSheets,
12338
12359
  mirror.getId(document)
12339
12360
  );
12361
+ console.log("full snapshot took", performance.now() - start, "ms");
12340
12362
  };
12341
12363
  try {
12342
12364
  const handlers = [];