@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.
@@ -956,6 +956,7 @@ function serializeTextNode(n2, options) {
956
956
  };
957
957
  }
958
958
  function serializeElementNode(n2, options) {
959
+ const start = performance.now();
959
960
  const {
960
961
  doc,
961
962
  blockClass,
@@ -1147,6 +1148,19 @@ function serializeElementNode(n2, options) {
1147
1148
  if (customElements.get(tagName)) isCustomElement = true;
1148
1149
  } catch (e2) {
1149
1150
  }
1151
+ const took = performance.now() - start;
1152
+ if (!window.serialization_perf_map) window.serialization_perf_map = {};
1153
+ if (!(tagName in window.serialization_perf_map)) {
1154
+ window.serialization_perf_map[tagName] = {
1155
+ avg: 0,
1156
+ times: []
1157
+ };
1158
+ }
1159
+ window.serialization_perf_map[tagName].times.push(took);
1160
+ if (window.serialization_perf_map[tagName].times.length > 1e3) {
1161
+ window.serialization_perf_map[tagName].times.shift();
1162
+ }
1163
+ 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;
1150
1164
  return {
1151
1165
  type: NodeType$3.Element,
1152
1166
  tagName,
@@ -1326,7 +1340,9 @@ function serializeNodeWithId(n2, options) {
1326
1340
  }
1327
1341
  let shadowRootEl = null;
1328
1342
  if (isElement(n2) && (shadowRootEl = index$1.shadowRoot(n2))) {
1329
- for (const childN of Array.from(index$1.childNodes(shadowRootEl))) {
1343
+ const childNodes2 = index$1.childNodes(shadowRootEl);
1344
+ for (let i2 = 0; i2 < childNodes2.length; i2++) {
1345
+ const childN = childNodes2[i2];
1330
1346
  const serializedChildNode = serializeNodeWithId(
1331
1347
  childN,
1332
1348
  bypassOptions
@@ -9438,10 +9454,12 @@ class MutationBuffer {
9438
9454
  __publicField(this, "tempPerfStore", {});
9439
9455
  __publicField(this, "processMutations", (mutations) => {
9440
9456
  const start = performance.now();
9457
+ let uniqueTypes = [];
9441
9458
  for (const mut of mutations) {
9442
9459
  const mutStart = performance.now();
9443
9460
  this.processMutation(mut);
9444
9461
  const took = performance.now() - mutStart;
9462
+ if (!uniqueTypes.includes(mut.type)) uniqueTypes.push(mut.type);
9445
9463
  if (!(mut.type in this.tempPerfStore)) {
9446
9464
  this.tempPerfStore[mut.type] = {
9447
9465
  avg: 0,
@@ -9458,7 +9476,9 @@ class MutationBuffer {
9458
9476
  mutations.length,
9459
9477
  "mutations processed in",
9460
9478
  performance.now() - start,
9461
- "ms"
9479
+ "ms",
9480
+ "types:",
9481
+ uniqueTypes
9462
9482
  );
9463
9483
  window.temp_perf_store = this.tempPerfStore;
9464
9484
  this.emit();
@@ -12304,6 +12324,7 @@ function record(options = {}) {
12304
12324
  if (!recordDOM) {
12305
12325
  return;
12306
12326
  }
12327
+ const start = performance.now();
12307
12328
  wrappedEmit(
12308
12329
  {
12309
12330
  type: EventType.Meta,
@@ -12371,6 +12392,7 @@ function record(options = {}) {
12371
12392
  document.adoptedStyleSheets,
12372
12393
  mirror.getId(document)
12373
12394
  );
12395
+ console.log("full snapshot took", performance.now() - start, "ms");
12374
12396
  };
12375
12397
  try {
12376
12398
  const handlers = [];