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