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