@fluidframework/id-compressor 2.0.0-rc.2.0.1 → 2.0.0-rc.3.0.0

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.
Files changed (130) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/api-report/id-compressor.api.md +2 -1
  3. package/dist/appendOnlySortedMap.js +2 -2
  4. package/dist/appendOnlySortedMap.js.map +1 -1
  5. package/dist/finalSpace.d.ts +1 -1
  6. package/dist/finalSpace.d.ts.map +1 -1
  7. package/dist/finalSpace.js +2 -2
  8. package/dist/finalSpace.js.map +1 -1
  9. package/dist/idCompressor.d.ts +1 -1
  10. package/dist/idCompressor.d.ts.map +1 -1
  11. package/dist/idCompressor.js +25 -24
  12. package/dist/idCompressor.js.map +1 -1
  13. package/dist/legacy.d.ts +28 -0
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.js +1 -1
  16. package/dist/packageVersion.js.map +1 -1
  17. package/dist/public.d.ts +18 -0
  18. package/dist/sessionSpaceNormalizer.d.ts +2 -0
  19. package/dist/sessionSpaceNormalizer.d.ts.map +1 -1
  20. package/dist/sessionSpaceNormalizer.js +44 -0
  21. package/dist/sessionSpaceNormalizer.js.map +1 -1
  22. package/dist/sessions.d.ts +1 -1
  23. package/dist/sessions.d.ts.map +1 -1
  24. package/dist/sessions.js +5 -5
  25. package/dist/sessions.js.map +1 -1
  26. package/dist/test/appendOnlySortedMap.perf.spec.js.map +1 -1
  27. package/dist/test/appendOnlySortedMap.spec.js.map +1 -1
  28. package/dist/test/idCompressor.perf.spec.js.map +1 -1
  29. package/dist/test/idCompressor.spec.js.map +1 -1
  30. package/dist/test/idCompressorTestUtilities.d.ts +2 -2
  31. package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
  32. package/dist/test/idCompressorTestUtilities.js +25 -1
  33. package/dist/test/idCompressorTestUtilities.js.map +1 -1
  34. package/dist/test/numericUuid.spec.js.map +1 -1
  35. package/dist/test/sessionSpaceNormalizer.spec.js.map +1 -1
  36. package/dist/test/snapshots/summary.spec.js.map +1 -1
  37. package/dist/test/testCommon.d.ts +1 -1
  38. package/dist/test/testCommon.d.ts.map +1 -1
  39. package/dist/test/testCommon.js +4 -4
  40. package/dist/test/testCommon.js.map +1 -1
  41. package/dist/types/idCompressor.d.ts +2 -2
  42. package/dist/types/idCompressor.d.ts.map +1 -1
  43. package/dist/types/idCompressor.js.map +1 -1
  44. package/dist/types/persisted-types/0.0.1.d.ts +4 -0
  45. package/dist/types/persisted-types/0.0.1.d.ts.map +1 -1
  46. package/dist/types/persisted-types/0.0.1.js.map +1 -1
  47. package/dist/utilities.d.ts +1 -1
  48. package/dist/utilities.d.ts.map +1 -1
  49. package/dist/utilities.js +2 -2
  50. package/dist/utilities.js.map +1 -1
  51. package/internal.d.ts +11 -0
  52. package/legacy.d.ts +11 -0
  53. package/lib/appendOnlySortedMap.js +1 -1
  54. package/lib/appendOnlySortedMap.js.map +1 -1
  55. package/lib/finalSpace.d.ts +1 -1
  56. package/lib/finalSpace.d.ts.map +1 -1
  57. package/lib/finalSpace.js +1 -1
  58. package/lib/finalSpace.js.map +1 -1
  59. package/lib/idCompressor.d.ts +1 -1
  60. package/lib/idCompressor.d.ts.map +1 -1
  61. package/lib/idCompressor.js +6 -5
  62. package/lib/idCompressor.js.map +1 -1
  63. package/lib/legacy.d.ts +28 -0
  64. package/lib/packageVersion.d.ts +1 -1
  65. package/lib/packageVersion.js +1 -1
  66. package/lib/packageVersion.js.map +1 -1
  67. package/lib/public.d.ts +18 -0
  68. package/lib/sessionSpaceNormalizer.d.ts +2 -0
  69. package/lib/sessionSpaceNormalizer.d.ts.map +1 -1
  70. package/lib/sessionSpaceNormalizer.js +44 -0
  71. package/lib/sessionSpaceNormalizer.js.map +1 -1
  72. package/lib/sessions.d.ts +1 -1
  73. package/lib/sessions.d.ts.map +1 -1
  74. package/lib/sessions.js +2 -2
  75. package/lib/sessions.js.map +1 -1
  76. package/lib/test/appendOnlySortedMap.perf.spec.js.map +1 -1
  77. package/lib/test/appendOnlySortedMap.spec.js.map +1 -1
  78. package/lib/test/idCompressor.perf.spec.js.map +1 -1
  79. package/lib/test/idCompressor.spec.js.map +1 -1
  80. package/lib/test/idCompressorTestUtilities.d.ts +2 -2
  81. package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
  82. package/lib/test/idCompressorTestUtilities.js +27 -3
  83. package/lib/test/idCompressorTestUtilities.js.map +1 -1
  84. package/lib/test/numericUuid.spec.js.map +1 -1
  85. package/lib/test/sessionSpaceNormalizer.spec.js.map +1 -1
  86. package/lib/test/snapshots/summary.spec.js.map +1 -1
  87. package/lib/test/testCommon.d.ts +1 -1
  88. package/lib/test/testCommon.d.ts.map +1 -1
  89. package/lib/test/testCommon.js +1 -1
  90. package/lib/test/testCommon.js.map +1 -1
  91. package/lib/types/idCompressor.d.ts +2 -2
  92. package/lib/types/idCompressor.d.ts.map +1 -1
  93. package/lib/types/idCompressor.js.map +1 -1
  94. package/lib/types/persisted-types/0.0.1.d.ts +4 -0
  95. package/lib/types/persisted-types/0.0.1.d.ts.map +1 -1
  96. package/lib/types/persisted-types/0.0.1.js.map +1 -1
  97. package/lib/utilities.d.ts +1 -1
  98. package/lib/utilities.d.ts.map +1 -1
  99. package/lib/utilities.js +1 -1
  100. package/lib/utilities.js.map +1 -1
  101. package/package.json +35 -65
  102. package/src/appendOnlySortedMap.ts +1 -1
  103. package/src/finalSpace.ts +3 -2
  104. package/src/idCompressor.ts +31 -25
  105. package/src/packageVersion.ts +1 -1
  106. package/src/sessionSpaceNormalizer.ts +63 -0
  107. package/src/sessions.ts +5 -4
  108. package/src/test/idCompressorTestUtilities.ts +38 -10
  109. package/src/test/testCommon.ts +4 -3
  110. package/src/test/tsconfig.json +1 -1
  111. package/src/types/idCompressor.ts +2 -2
  112. package/src/types/persisted-types/0.0.1.ts +5 -0
  113. package/src/utilities.ts +3 -2
  114. package/api-extractor-cjs.json +0 -8
  115. package/dist/id-compressor-alpha.d.ts +0 -352
  116. package/dist/id-compressor-beta.d.ts +0 -179
  117. package/dist/id-compressor-public.d.ts +0 -179
  118. package/dist/id-compressor-untrimmed.d.ts +0 -365
  119. package/lib/id-compressor-alpha.d.ts +0 -352
  120. package/lib/id-compressor-beta.d.ts +0 -179
  121. package/lib/id-compressor-public.d.ts +0 -179
  122. package/lib/id-compressor-untrimmed.d.ts +0 -365
  123. package/lib/test/appendOnlySortedMap.perf.spec.js +0 -49
  124. package/lib/test/appendOnlySortedMap.spec.js +0 -166
  125. package/lib/test/idCompressor.perf.spec.js +0 -281
  126. package/lib/test/idCompressor.spec.js +0 -953
  127. package/lib/test/numericUuid.spec.js +0 -74
  128. package/lib/test/sessionSpaceNormalizer.spec.js +0 -43
  129. package/lib/test/snapshots/summary.spec.js +0 -127
  130. /package/{dist → lib}/tsdoc-metadata.json +0 -0
@@ -1,166 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /* eslint-disable no-bitwise */
6
- import { strict as assert } from "assert";
7
- import { AppendOnlySortedMap } from "../appendOnlySortedMap.js";
8
- import { compareFiniteNumbers } from "../utilities.js";
9
- import { assertNotUndefined } from "./testCommon.js";
10
- function runAppendOnlyMapTests(mapBuilder) {
11
- it("detects out-of-order keys", () => {
12
- const map = mapBuilder();
13
- map.append(0, 0);
14
- const exception = "Inserted key must be > all others in the map.";
15
- assert.throws(() => map.append(-1, 1), (e) => e.message === exception);
16
- map.append(1, 2);
17
- });
18
- it("can get the min and max keys", () => {
19
- const map = mapBuilder();
20
- const elementCount = 10;
21
- assert.equal(map.maxKey(), undefined);
22
- for (let i = 0; i < elementCount; i++) {
23
- map.append(i, i);
24
- assert.equal(map.maxKey(), i);
25
- assert.equal(map.minKey(), 0);
26
- }
27
- });
28
- it("can get the first and last pairs", () => {
29
- const map = mapBuilder();
30
- const elementCount = 10;
31
- assert.equal(map.first(), undefined);
32
- assert.equal(map.last(), undefined);
33
- for (let i = 0; i < elementCount; i++) {
34
- map.append(i, i);
35
- assert.deepEqual(map.last(), [i, i]);
36
- assert.deepEqual(map.first(), [0, 0]);
37
- }
38
- });
39
- it("can get values", () => {
40
- const map = mapBuilder();
41
- const elementCount = 10;
42
- for (let i = 0; i < elementCount; i++) {
43
- map.append(i, i);
44
- }
45
- assert.equal(map.get(-1), undefined);
46
- assert.equal(map.get(10), undefined);
47
- for (let i = 0; i < elementCount; i++) {
48
- assert.equal(map.get(i), i);
49
- }
50
- });
51
- it("can get pairs by index", () => {
52
- const map = mapBuilder();
53
- const elementCount = 10;
54
- for (let i = 0; i < elementCount; i++) {
55
- map.append(i * 10, i);
56
- }
57
- assert.equal(map.getAtIndex(-1), undefined);
58
- assert.equal(map.getAtIndex(10), undefined);
59
- for (let i = 0; i < elementCount; i++) {
60
- assert.deepEqual(map.getAtIndex(i), [i * 10, i]);
61
- }
62
- });
63
- it("can get an entry or next lower by key", () => {
64
- [99, 100].forEach((elementCount) => {
65
- const map = mapBuilder();
66
- for (let i = 0; i < elementCount; i++) {
67
- map.append(i * 2, i * 2);
68
- }
69
- assert.equal(map.getPairOrNextLower(-1), undefined);
70
- for (let i = 0; i < map.size; i++) {
71
- assert.deepEqual(map.getPairOrNextLower(i * 2), [i * 2, i * 2]);
72
- assert.deepEqual(map.getPairOrNextLower(i * 2 + 1), [i * 2, i * 2]);
73
- }
74
- const maxKey = assertNotUndefined(map.maxKey());
75
- assert.deepEqual(map.getPairOrNextLower(maxKey + 1), [maxKey, maxKey]);
76
- });
77
- });
78
- it("can get an entry or next higher by key", () => {
79
- [99, 100].forEach((elementCount) => {
80
- const map = mapBuilder();
81
- for (let i = 0; i < elementCount; i++) {
82
- map.append(i * 2, i * 2);
83
- }
84
- const minKey = assertNotUndefined(map.minKey());
85
- assert.deepEqual(map.getPairOrNextHigher(minKey - 1), [minKey, minKey]);
86
- for (let i = 0; i < map.size - 1; i++) {
87
- assert.deepEqual(map.getPairOrNextHigher(i * 2), [i * 2, i * 2]);
88
- assert.deepEqual(map.getPairOrNextHigher(i * 2 + 1), [i * 2 + 2, i * 2 + 2]);
89
- }
90
- assert.equal(map.getPairOrNextHigher(map.size * 2 + 1), undefined);
91
- });
92
- });
93
- it("knows how big it is", () => {
94
- const map = mapBuilder();
95
- const elementCount = 10;
96
- for (let i = 0; i < elementCount; i++) {
97
- assert.equal(map.size, i);
98
- map.append(i, i);
99
- }
100
- assert.equal(map.size, elementCount);
101
- });
102
- it("can enumerate its keys and values", () => {
103
- const map = mapBuilder();
104
- const elementCount = 10;
105
- const keys = [];
106
- const values = [];
107
- for (let i = 0; i < elementCount; i++) {
108
- const key = i;
109
- const value = i * 2;
110
- map.append(key, value);
111
- keys.push(key);
112
- values.push(value);
113
- }
114
- assert.deepEqual([...map.keys()], keys);
115
- assert.deepEqual([...map.values()], values);
116
- });
117
- it("can calculate the indexOf a search element", () => {
118
- const elements = [0, 0, 2, 0, 3, 0];
119
- const comparator = (search, key, value) => {
120
- return compareFiniteNumbers(search, key);
121
- };
122
- assert.equal(AppendOnlySortedMap.keyIndexOf(elements, 0, comparator), 0);
123
- assert.equal(AppendOnlySortedMap.keyIndexOf(elements, 2, comparator), 2);
124
- assert.equal(AppendOnlySortedMap.keyIndexOf(elements, 3, comparator), 4);
125
- assert.equal(AppendOnlySortedMap.keyIndexOf(elements, -1, comparator), 0 ^ AppendOnlySortedMap.failureXor);
126
- assert.equal(AppendOnlySortedMap.keyIndexOf(elements, 1, comparator), 2 ^ AppendOnlySortedMap.failureXor);
127
- assert.equal(AppendOnlySortedMap.keyIndexOf(elements, 10, comparator), 6 ^ AppendOnlySortedMap.failureXor);
128
- });
129
- describe("can perform range queries", () => {
130
- const map = mapBuilder();
131
- const elementCount = 10;
132
- for (let i = 0; i < elementCount; i++) {
133
- map.append(i * 2, i * 2);
134
- }
135
- const maxKey = assertNotUndefined(map.maxKey());
136
- it("on empty ranges", () => {
137
- assert.deepEqual([...map.getRange(1, -1)], []);
138
- assert.deepEqual([...map.getRange(maxKey + 1, maxKey + 1)], []);
139
- });
140
- it("on ranges of size 1", () => {
141
- assert.deepEqual([...map.getRange(0, 0)], [[0, 0]]);
142
- assert.deepEqual([...map.getRange(1, 1)], []);
143
- assert.deepEqual([...map.getRange(-1, -1)], []);
144
- });
145
- it("on non-empty ranges", () => {
146
- assert.deepEqual([...map.getRange(0, 1)], [[0, 0]]);
147
- assert.deepEqual([...map.getRange(0, 2)], [
148
- [0, 0],
149
- [2, 2],
150
- ]);
151
- assert.deepEqual([...map.getRange(1, 5)], [
152
- [2, 2],
153
- [4, 4],
154
- ]);
155
- const allEntries = [...map.entries()];
156
- assert.deepEqual([...map.getRange(0, maxKey)], allEntries);
157
- assert.deepEqual([...map.getRange(-maxKey, maxKey)], allEntries);
158
- assert.deepEqual([...map.getRange(0, 2 * maxKey)], allEntries);
159
- assert.deepEqual([...map.getRange(-maxKey, 2 * maxKey)], allEntries);
160
- });
161
- });
162
- }
163
- describe("AppendOnlySortedMap", () => {
164
- runAppendOnlyMapTests(() => new AppendOnlySortedMap(compareFiniteNumbers));
165
- });
166
- //# sourceMappingURL=appendOnlySortedMap.spec.js.map
@@ -1,281 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
6
- import { benchmark, BenchmarkType } from "@fluid-tools/benchmark";
7
- import { assert } from "@fluidframework/core-utils";
8
- import { take } from "@fluid-private/stochastic-test-utils";
9
- import { IdCompressor } from "../idCompressor.js";
10
- import { createSessionId } from "../utilities.js";
11
- import { isFinalId, isLocalId, fail } from "./testCommon.js";
12
- import { Client, DestinationClient, IdCompressorTestNetwork, buildHugeCompressor, makeOpGenerator, performFuzzActions, sessionIds, } from "./idCompressorTestUtilities.js";
13
- const initialClusterCapacity = 512;
14
- describe("IdCompressor Perf", () => {
15
- const type = BenchmarkType.Measurement;
16
- const localClient = Client.Client1;
17
- const remoteClient = Client.Client2;
18
- let perfCompressor;
19
- function setupCompressors(clusterSize, localClientCanEdit, synchronizeAtEnd) {
20
- const perfNetwork = new IdCompressorTestNetwork(clusterSize);
21
- const maxClusterSize = clusterSize * 2;
22
- const generator = take(1000, makeOpGenerator({
23
- validateInterval: 2000,
24
- maxClusterSize,
25
- outsideAllocationFraction: 0.9,
26
- }));
27
- performFuzzActions(generator, perfNetwork, Math.E, localClientCanEdit ? undefined : localClient, synchronizeAtEnd);
28
- perfCompressor = perfNetwork.getCompressorUnsafeNoProxy(localClient);
29
- return perfNetwork;
30
- }
31
- function getIdMadeBy(client, eagerFinal, network) {
32
- const log = network.getIdLog(client);
33
- for (let i = log.length - 1; i > 0; i--) {
34
- const { id, originatingClient } = log[i];
35
- if (originatingClient === client) {
36
- if ((eagerFinal && isFinalId(id)) || (!eagerFinal && isLocalId(id))) {
37
- assert(eagerFinal === isFinalId(id), "Not local/final as requested.");
38
- return id;
39
- }
40
- }
41
- }
42
- fail("no ID found in log");
43
- }
44
- function benchmarkWithFlag(creator) {
45
- for (const flag of [true, false]) {
46
- creator(flag);
47
- }
48
- }
49
- benchmark({
50
- type,
51
- title: `allocate local ID`,
52
- before: () => {
53
- setupCompressors(initialClusterCapacity, true, true);
54
- },
55
- benchmarkFn: () => {
56
- perfCompressor.generateCompressedId();
57
- },
58
- });
59
- benchmark({
60
- type,
61
- title: "take an ID creation range",
62
- before: () => {
63
- setupCompressors(initialClusterCapacity, true, true);
64
- },
65
- benchmarkFn: () => {
66
- perfCompressor.generateCompressedId();
67
- perfCompressor.takeNextCreationRange();
68
- },
69
- });
70
- for (const clusterSize of [1, 10, 500, 1000]) {
71
- const numIds = 7;
72
- const session1 = "8150a099-5302-4672-b5f3-7a4492b59418";
73
- const session2 = "f2ded886-92da-4248-967b-eb96ee04cf51";
74
- let session = session1;
75
- let nextFirstFinalizedGenCount1 = 1;
76
- let nextFirstFinalizedGenCount2 = 1;
77
- benchmark({
78
- type,
79
- title: `finalize a range of IDs (cluster size = ${clusterSize})`,
80
- before: () => {
81
- setupCompressors(clusterSize, false, true);
82
- },
83
- benchmarkFn: () => {
84
- // Create a range with as minimal overhead as possible, as we'd like for this code to not exist
85
- // in the timing loop at all (but benchmark forces us to do so)
86
- const isFirstClient = session === session1;
87
- const firstGenCount = isFirstClient
88
- ? nextFirstFinalizedGenCount1
89
- : nextFirstFinalizedGenCount2;
90
- const range = {
91
- sessionId: session,
92
- ids: {
93
- firstGenCount,
94
- count: numIds,
95
- requestedClusterSize: initialClusterCapacity,
96
- },
97
- };
98
- perfCompressor.finalizeCreationRange(range);
99
- const lastGenCount = firstGenCount + numIds;
100
- if (isFirstClient) {
101
- nextFirstFinalizedGenCount1 = lastGenCount;
102
- }
103
- else {
104
- nextFirstFinalizedGenCount2 = lastGenCount;
105
- }
106
- // Alternate clients to sidestep optimization that packs them all into last cluster
107
- session = isFirstClient ? session1 : session2;
108
- },
109
- });
110
- }
111
- benchmarkWithFlag((isLocal) => {
112
- const remoteSessionId = sessionIds.get(remoteClient);
113
- let opSpaceId;
114
- benchmark({
115
- type,
116
- title: `normalize a ${isLocal ? "local" : "final"} ID from a remote session to session space`,
117
- before: () => {
118
- const network = setupCompressors(initialClusterCapacity, true, true);
119
- const remoteSession = getIdMadeBy(remoteClient, false, network);
120
- opSpaceId = (isLocal
121
- ? remoteSession
122
- : network.getCompressor(remoteClient).normalizeToOpSpace(remoteSession));
123
- },
124
- benchmarkFn: () => {
125
- perfCompressor.normalizeToSessionSpace(opSpaceId, remoteSessionId);
126
- },
127
- });
128
- });
129
- benchmarkWithFlag((eagerFinal) => {
130
- let id;
131
- benchmark({
132
- type,
133
- title: `normalize a final ID corresponding to a ${eagerFinal ? "eager final" : "local"} ID from op space to the local session`,
134
- before: () => {
135
- const network = setupCompressors(initialClusterCapacity, true, true);
136
- const opId = perfCompressor.normalizeToOpSpace(getIdMadeBy(localClient, eagerFinal, network));
137
- assert(isFinalId(opId), "Must be final");
138
- id = opId;
139
- },
140
- benchmarkFn: () => {
141
- perfCompressor.normalizeToSessionSpace(id, perfCompressor.localSessionId);
142
- },
143
- });
144
- });
145
- benchmarkWithFlag((isLocalOriginator) => {
146
- const remoteSessionId = sessionIds.get(remoteClient);
147
- let opSpaceId;
148
- benchmark({
149
- type,
150
- title: `normalize a final ID from a ${isLocalOriginator ? "local" : "remote"} session to a small session space (common case)`,
151
- before: () => {
152
- const network = setupCompressors(initialClusterCapacity, false, true);
153
- // Ensure the local session has several different clusters
154
- for (let clusterCount = 0; clusterCount < 5; clusterCount++) {
155
- network.allocateAndSendIds(localClient,
156
- // eslint-disable-next-line @typescript-eslint/dot-notation
157
- perfCompressor["nextRequestedClusterSize"]);
158
- network.allocateAndSendIds(remoteClient,
159
- // eslint-disable-next-line @typescript-eslint/dot-notation
160
- perfCompressor["nextRequestedClusterSize"] * 2);
161
- network.deliverOperations(DestinationClient.All);
162
- }
163
- const client = isLocalOriginator ? localClient : remoteClient;
164
- const idFromSession = getIdMadeBy(client, true, network);
165
- opSpaceId = network.getCompressor(client).normalizeToOpSpace(idFromSession);
166
- },
167
- benchmarkFn: () => {
168
- perfCompressor.normalizeToSessionSpace(opSpaceId, remoteSessionId);
169
- },
170
- });
171
- });
172
- let unackedLocalId;
173
- benchmark({
174
- type,
175
- title: `normalize an unacked local ID from the local session to op space`,
176
- before: () => {
177
- const network = setupCompressors(initialClusterCapacity, true, false);
178
- // Ensure no eager finals
179
- network.allocateAndSendIds(localClient,
180
- // eslint-disable-next-line @typescript-eslint/dot-notation
181
- network.getCompressor(localClient)["nextRequestedClusterSize"] * 2 + 1);
182
- unackedLocalId = getIdMadeBy(localClient, false, network);
183
- assert(perfCompressor.normalizeToOpSpace(unackedLocalId) === unackedLocalId, "Local was acked.");
184
- },
185
- benchmarkFn: () => {
186
- perfCompressor.normalizeToOpSpace(unackedLocalId);
187
- },
188
- });
189
- benchmarkWithFlag((eagerFinal) => {
190
- let id;
191
- benchmark({
192
- type,
193
- title: `normalize an acked ${eagerFinal ? "eager final" : "local"} ID from the local session to op space`,
194
- before: () => {
195
- const network = setupCompressors(initialClusterCapacity, true, true);
196
- id = getIdMadeBy(localClient, eagerFinal, network);
197
- },
198
- benchmarkFn: () => {
199
- perfCompressor.normalizeToOpSpace(id);
200
- },
201
- });
202
- });
203
- benchmarkWithFlag((local) => {
204
- let finalIdToDecompress;
205
- benchmark({
206
- type,
207
- title: `decompress a final ID from a ${local ? "local" : "remote"} client into a stable ID`,
208
- before: () => {
209
- const network = setupCompressors(initialClusterCapacity, true, true);
210
- finalIdToDecompress = getIdMadeBy(local ? localClient : remoteClient, true, network);
211
- },
212
- benchmarkFn: () => {
213
- perfCompressor.decompress(finalIdToDecompress);
214
- },
215
- });
216
- });
217
- let localIdToDecompress;
218
- benchmark({
219
- type,
220
- title: `decompress a local ID into a stable ID`,
221
- before: () => {
222
- const network = setupCompressors(initialClusterCapacity, true, true);
223
- localIdToDecompress = getIdMadeBy(localClient, false, network);
224
- },
225
- benchmarkFn: () => {
226
- perfCompressor.decompress(localIdToDecompress);
227
- },
228
- });
229
- benchmarkWithFlag((eagerFinal) => {
230
- let stableToCompress;
231
- benchmark({
232
- type,
233
- title: `recompress a stable ID to a ${eagerFinal ? "local" : "final"} ID`,
234
- before: () => {
235
- const network = setupCompressors(initialClusterCapacity, true, true);
236
- stableToCompress = perfCompressor.decompress(getIdMadeBy(localClient, eagerFinal, network));
237
- },
238
- benchmarkFn: () => {
239
- perfCompressor.recompress(stableToCompress);
240
- },
241
- });
242
- });
243
- benchmarkWithFlag((manySessions) => {
244
- benchmark({
245
- type,
246
- title: `serialize an IdCompressor (${manySessions ? "many sessions" : "many clusters"})`,
247
- before: () => {
248
- if (manySessions) {
249
- perfCompressor = buildHugeCompressor(undefined, initialClusterCapacity);
250
- }
251
- else {
252
- setupCompressors(initialClusterCapacity, false, true);
253
- }
254
- },
255
- benchmarkFn: () => {
256
- perfCompressor.serialize(false);
257
- },
258
- });
259
- });
260
- benchmarkWithFlag((manySessions) => {
261
- let serialized;
262
- const overrideRemoteSessionId = createSessionId();
263
- benchmark({
264
- type,
265
- title: `deserialize an IdCompressor (${manySessions ? "many sessions" : "many clusters"})`,
266
- before: () => {
267
- if (manySessions) {
268
- perfCompressor = buildHugeCompressor(undefined, initialClusterCapacity);
269
- }
270
- else {
271
- setupCompressors(initialClusterCapacity, false, true);
272
- }
273
- serialized = perfCompressor.serialize(false);
274
- },
275
- benchmarkFn: () => {
276
- IdCompressor.deserialize(serialized, overrideRemoteSessionId);
277
- },
278
- });
279
- });
280
- });
281
- //# sourceMappingURL=idCompressor.perf.spec.js.map