@fluidframework/merge-tree 2.93.0 → 2.101.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.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/sequencePlace.d.ts +13 -0
- package/dist/sequencePlace.d.ts.map +1 -1
- package/dist/sequencePlace.js +17 -4
- package/dist/sequencePlace.js.map +1 -1
- package/dist/test/Insertion.perf.spec.js +52 -39
- package/dist/test/Insertion.perf.spec.js.map +1 -1
- package/dist/test/PartialLengths.perf.spec.js +44 -41
- package/dist/test/PartialLengths.perf.spec.js.map +1 -1
- package/dist/test/Removal.perf.spec.js +105 -100
- package/dist/test/Removal.perf.spec.js.map +1 -1
- package/dist/test/Snapshot.perf.spec.js +14 -18
- package/dist/test/Snapshot.perf.spec.js.map +1 -1
- package/dist/test/attributionCollection.perf.spec.js +41 -31
- package/dist/test/attributionCollection.perf.spec.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/sequencePlace.d.ts +13 -0
- package/lib/sequencePlace.d.ts.map +1 -1
- package/lib/sequencePlace.js +16 -3
- package/lib/sequencePlace.js.map +1 -1
- package/lib/test/Insertion.perf.spec.js +53 -40
- package/lib/test/Insertion.perf.spec.js.map +1 -1
- package/lib/test/PartialLengths.perf.spec.js +45 -42
- package/lib/test/PartialLengths.perf.spec.js.map +1 -1
- package/lib/test/Removal.perf.spec.js +106 -101
- package/lib/test/Removal.perf.spec.js.map +1 -1
- package/lib/test/Snapshot.perf.spec.js +15 -19
- package/lib/test/Snapshot.perf.spec.js.map +1 -1
- package/lib/test/attributionCollection.perf.spec.js +42 -32
- package/lib/test/attributionCollection.perf.spec.js.map +1 -1
- package/package.json +18 -18
- package/src/index.ts +1 -0
- package/src/sequencePlace.ts +17 -3
package/lib/sequencePlace.d.ts
CHANGED
|
@@ -48,6 +48,19 @@ export declare enum Side {
|
|
|
48
48
|
Before = 0,
|
|
49
49
|
After = 1
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The {@link Side} a bare numeric `SequencePlace` resolves to when no side is
|
|
53
|
+
* explicitly provided. Exported so callers that need to detect "the caller
|
|
54
|
+
* didn't specify a side" (such as serialized op replay) can compare against
|
|
55
|
+
* this without hardcoding `Side.Before`.
|
|
56
|
+
*
|
|
57
|
+
* Note: this only governs the bare-numeric case. The `"start"` and `"end"`
|
|
58
|
+
* literals are normalized by `normalizePlace` with their own conventions
|
|
59
|
+
* (`"start"` → `Side.After`, `"end"` → `Side.Before`) and are unrelated to
|
|
60
|
+
* `defaultSide`.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare const defaultSide = Side.Before;
|
|
51
64
|
/**
|
|
52
65
|
* Returns the position and side of the start and end of a sequence.
|
|
53
66
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencePlace.d.ts","sourceRoot":"","sources":["../src/sequencePlace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,qBAAqB,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,IAAI,CAAC;CACX;AAED;;;;;GAKG;AACH,oBAAY,IAAI;IACf,MAAM,IAAI;IACV,KAAK,IAAI;CACT;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,GAAG,EAAE,aAAa,GAAG,SAAS,GAC5B;IACF,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,IAAI,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;IAC/C,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;CAC7C,CAiBA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,qBAAqB,CAW1E"}
|
|
1
|
+
{"version":3,"file":"sequencePlace.d.ts","sourceRoot":"","sources":["../src/sequencePlace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,qBAAqB,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,IAAI,CAAC;CACX;AAED;;;;;GAKG;AACH,oBAAY,IAAI;IACf,MAAM,IAAI;IACV,KAAK,IAAI;CACT;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,cAAc,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,GAAG,EAAE,aAAa,GAAG,SAAS,GAC5B;IACF,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,IAAI,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;IAC/C,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;CAC7C,CAiBA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,qBAAqB,CAW1E"}
|
package/lib/sequencePlace.js
CHANGED
|
@@ -13,6 +13,19 @@ export var Side;
|
|
|
13
13
|
Side[Side["Before"] = 0] = "Before";
|
|
14
14
|
Side[Side["After"] = 1] = "After";
|
|
15
15
|
})(Side || (Side = {}));
|
|
16
|
+
/**
|
|
17
|
+
* The {@link Side} a bare numeric `SequencePlace` resolves to when no side is
|
|
18
|
+
* explicitly provided. Exported so callers that need to detect "the caller
|
|
19
|
+
* didn't specify a side" (such as serialized op replay) can compare against
|
|
20
|
+
* this without hardcoding `Side.Before`.
|
|
21
|
+
*
|
|
22
|
+
* Note: this only governs the bare-numeric case. The `"start"` and `"end"`
|
|
23
|
+
* literals are normalized by `normalizePlace` with their own conventions
|
|
24
|
+
* (`"start"` → `Side.After`, `"end"` → `Side.Before`) and are unrelated to
|
|
25
|
+
* `defaultSide`.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export const defaultSide = Side.Before;
|
|
16
29
|
/**
|
|
17
30
|
* Returns the position and side of the start and end of a sequence.
|
|
18
31
|
*
|
|
@@ -21,8 +34,8 @@ export var Side;
|
|
|
21
34
|
export function endpointPosAndSide(start, end) {
|
|
22
35
|
const startIsPlainEndpoint = typeof start === "number" || start === "start" || start === "end";
|
|
23
36
|
const endIsPlainEndpoint = typeof end === "number" || end === "start" || end === "end";
|
|
24
|
-
const startSide = startIsPlainEndpoint ?
|
|
25
|
-
const endSide = endIsPlainEndpoint ?
|
|
37
|
+
const startSide = startIsPlainEndpoint ? defaultSide : start?.side;
|
|
38
|
+
const endSide = endIsPlainEndpoint ? defaultSide : end?.side;
|
|
26
39
|
const startPos = startIsPlainEndpoint ? start : start?.pos;
|
|
27
40
|
const endPos = endIsPlainEndpoint ? end : end?.pos;
|
|
28
41
|
return {
|
|
@@ -37,7 +50,7 @@ export function endpointPosAndSide(start, end) {
|
|
|
37
50
|
*/
|
|
38
51
|
export function normalizePlace(place) {
|
|
39
52
|
if (typeof place === "number") {
|
|
40
|
-
return { pos: place, side:
|
|
53
|
+
return { pos: place, side: defaultSide };
|
|
41
54
|
}
|
|
42
55
|
if (place === "start") {
|
|
43
56
|
return { pos: -1, side: Side.After };
|
package/lib/sequencePlace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencePlace.js","sourceRoot":"","sources":["../src/sequencePlace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwCH;;;;;GAKG;AACH,MAAM,CAAN,IAAY,IAGX;AAHD,WAAY,IAAI;IACf,mCAAU,CAAA;IACV,iCAAS,CAAA;AACV,CAAC,EAHW,IAAI,KAAJ,IAAI,QAGf;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAgC,EAChC,GAA8B;IAO9B,MAAM,oBAAoB,GACzB,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,KAAK,CAAC;IACnE,MAAM,kBAAkB,GAAG,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,KAAK,CAAC;IAEvF,MAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"sequencePlace.js","sourceRoot":"","sources":["../src/sequencePlace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwCH;;;;;GAKG;AACH,MAAM,CAAN,IAAY,IAGX;AAHD,WAAY,IAAI;IACf,mCAAU,CAAA;IACV,iCAAS,CAAA;AACV,CAAC,EAHW,IAAI,KAAJ,IAAI,QAGf;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAgC,EAChC,GAA8B;IAO9B,MAAM,oBAAoB,GACzB,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,KAAK,CAAC;IACnE,MAAM,kBAAkB,GAAG,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,KAAK,CAAC;IAEvF,MAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC;IACnE,MAAM,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC;IAE7D,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC;IAC3D,MAAM,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;IAEnD,OAAO;QACN,SAAS;QACT,OAAO;QACP,QAAQ;QACR,MAAM;KACN,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAoB;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC1C,CAAC;IACD,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACtC,CAAC;IACD,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Defines a position and side relative to a character in a sequence.\n *\n * For this purpose, sequences look like:\n *\n * `{start} - {character 0} - {character 1} - ... - {character N} - {end}`\n *\n * Each `{value}` in the diagram is a character within a sequence.\n * Each `-` in the above diagram is a position where text could be inserted.\n * Each position between a `{value}` and a `-` is a `SequencePlace`.\n *\n * The special endpoints `{start}` and `{end}` refer to positions outside the\n * contents of the string.\n *\n * This gives us 2N + 2 possible positions to refer to within a string, where N\n * is the number of characters.\n *\n * If the position is specified with a bare number, the side defaults to\n * `Side.Before`.\n *\n * If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),\n * the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.\n * E.g. the start of a range with Side.After is exclusive of the character at the position.\n * @legacy @beta\n */\nexport type SequencePlace = number | \"start\" | \"end\" | InteriorSequencePlace;\n\n/**\n * A sequence place that does not refer to the special endpoint segments.\n *\n * See {@link SequencePlace} for additional context.\n * @legacy @beta\n */\nexport interface InteriorSequencePlace {\n\tpos: number;\n\tside: Side;\n}\n\n/**\n * Defines a side relative to a character in a sequence.\n *\n * @remarks See {@link SequencePlace} for additional context on usage.\n * @legacy @beta\n */\nexport enum Side {\n\tBefore = 0,\n\tAfter = 1,\n}\n\n/**\n * The {@link Side} a bare numeric `SequencePlace` resolves to when no side is\n * explicitly provided. Exported so callers that need to detect \"the caller\n * didn't specify a side\" (such as serialized op replay) can compare against\n * this without hardcoding `Side.Before`.\n *\n * Note: this only governs the bare-numeric case. The `\"start\"` and `\"end\"`\n * literals are normalized by `normalizePlace` with their own conventions\n * (`\"start\"` → `Side.After`, `\"end\"` → `Side.Before`) and are unrelated to\n * `defaultSide`.\n * @internal\n */\nexport const defaultSide = Side.Before;\n\n/**\n * Returns the position and side of the start and end of a sequence.\n *\n * @legacy @beta\n */\nexport function endpointPosAndSide(\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n): {\n\tstartSide: Side | undefined;\n\tendSide: Side | undefined;\n\tstartPos: number | \"start\" | \"end\" | undefined;\n\tendPos: number | \"start\" | \"end\" | undefined;\n} {\n\tconst startIsPlainEndpoint =\n\t\ttypeof start === \"number\" || start === \"start\" || start === \"end\";\n\tconst endIsPlainEndpoint = typeof end === \"number\" || end === \"start\" || end === \"end\";\n\n\tconst startSide = startIsPlainEndpoint ? defaultSide : start?.side;\n\tconst endSide = endIsPlainEndpoint ? defaultSide : end?.side;\n\n\tconst startPos = startIsPlainEndpoint ? start : start?.pos;\n\tconst endPos = endIsPlainEndpoint ? end : end?.pos;\n\n\treturn {\n\t\tstartSide,\n\t\tendSide,\n\t\tstartPos,\n\t\tendPos,\n\t};\n}\n\n/**\n * Returns the given place in InteriorSequencePlace form.\n */\nexport function normalizePlace(place: SequencePlace): InteriorSequencePlace {\n\tif (typeof place === \"number\") {\n\t\treturn { pos: place, side: defaultSide };\n\t}\n\tif (place === \"start\") {\n\t\treturn { pos: -1, side: Side.After };\n\t}\n\tif (place === \"end\") {\n\t\treturn { pos: -1, side: Side.Before };\n\t}\n\treturn place;\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { benchmarkDuration, benchmarkIt } from "@fluid-tools/benchmark";
|
|
6
6
|
import { MergeTree } from "../mergeTree.js";
|
|
7
7
|
import { MergeTreeDeltaType } from "../ops.js";
|
|
8
8
|
import { TextSegment } from "../textSegment.js";
|
|
@@ -15,52 +15,65 @@ function constructTree(numOfSegments) {
|
|
|
15
15
|
}
|
|
16
16
|
const TREE_SIZE = 7500;
|
|
17
17
|
describe("MergeTree insertion", () => {
|
|
18
|
-
|
|
19
|
-
type: BenchmarkType.Measurement,
|
|
18
|
+
benchmarkIt({
|
|
20
19
|
title: "insert into empty tree",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
...benchmarkDuration({
|
|
21
|
+
benchmarkFn: () => {
|
|
22
|
+
const emptyTree = new MergeTree();
|
|
23
|
+
emptyTree.insertSegments(0, [TextSegment.make("a")], emptyTree.localPerspective, { seq: 0, clientId: 0 }, { op: { type: MergeTreeDeltaType.INSERT } });
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
25
26
|
});
|
|
26
|
-
|
|
27
|
-
benchmark({
|
|
28
|
-
type: BenchmarkType.Measurement,
|
|
27
|
+
benchmarkIt({
|
|
29
28
|
title: "insert at start of large tree",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
...benchmarkDuration({
|
|
30
|
+
benchmarkFnCustom: async (state) => {
|
|
31
|
+
let startTree = constructTree(TREE_SIZE);
|
|
32
|
+
let keepRunning;
|
|
33
|
+
do {
|
|
34
|
+
startTree = constructTree(TREE_SIZE);
|
|
35
|
+
keepRunning = state.timeBatch(() => {
|
|
36
|
+
for (let i = TREE_SIZE; i < TREE_SIZE + 25; i++) {
|
|
37
|
+
startTree.insertSegments(0, [TextSegment.make("a")], startTree.localPerspective, { seq: i + 1, clientId: 0 }, { op: { type: MergeTreeDeltaType.INSERT } });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} while (keepRunning);
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
38
43
|
});
|
|
39
|
-
|
|
40
|
-
benchmark({
|
|
41
|
-
type: BenchmarkType.Measurement,
|
|
44
|
+
benchmarkIt({
|
|
42
45
|
title: "insert at middle of large tree",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
middleTree
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
...benchmarkDuration({
|
|
47
|
+
benchmarkFnCustom: async (state) => {
|
|
48
|
+
let middleTree = constructTree(TREE_SIZE);
|
|
49
|
+
let keepRunning;
|
|
50
|
+
do {
|
|
51
|
+
middleTree = constructTree(TREE_SIZE);
|
|
52
|
+
keepRunning = state.timeBatch(() => {
|
|
53
|
+
for (let i = TREE_SIZE; i < TREE_SIZE + 25; i++) {
|
|
54
|
+
middleTree.insertSegments(TREE_SIZE / 2, [TextSegment.make("a")], middleTree.localPerspective, { seq: i + 1, clientId: 0 }, { op: { type: MergeTreeDeltaType.INSERT } });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
} while (keepRunning);
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
51
60
|
});
|
|
52
|
-
|
|
53
|
-
benchmark({
|
|
54
|
-
type: BenchmarkType.Measurement,
|
|
61
|
+
benchmarkIt({
|
|
55
62
|
title: "insert at end of large tree",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
...benchmarkDuration({
|
|
64
|
+
benchmarkFnCustom: async (state) => {
|
|
65
|
+
let endTree = constructTree(TREE_SIZE);
|
|
66
|
+
let keepRunning;
|
|
67
|
+
do {
|
|
68
|
+
endTree = constructTree(TREE_SIZE);
|
|
69
|
+
keepRunning = state.timeBatch(() => {
|
|
70
|
+
for (let i = TREE_SIZE; i < TREE_SIZE + 25; i++) {
|
|
71
|
+
endTree.insertSegments(i, [TextSegment.make("a")], endTree.localPerspective, { seq: i + 1, clientId: 0 }, { op: { type: MergeTreeDeltaType.INSERT } });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
} while (keepRunning);
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
64
77
|
});
|
|
65
78
|
});
|
|
66
79
|
//# sourceMappingURL=Insertion.perf.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Insertion.perf.spec.js","sourceRoot":"","sources":["../../src/test/Insertion.perf.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Insertion.perf.spec.js","sourceRoot":"","sources":["../../src/test/Insertion.perf.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CA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,CAAC,CAAC,EACvB,UAAU,CAAC,gBAAgB,EAC3B,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAC3B,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAC3C,CAAC;wBACH,CAAC;oBACF,CAAC,CAAC,CAAC;gBACJ,CAAC,QAAQ,WAAW,EAAE;YACvB,CAAC;SACD,CAAC;KACF,CAAC,CAAC;IAEH,WAAW,CAAC;QACX,KAAK,EAAE,6BAA6B;QACpC,GAAG,iBAAiB,CAAC;YACpB,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;gBAClC,IAAI,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;gBACvC,IAAI,WAAoB,CAAC;gBACzB,GAAG,CAAC;oBACH,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;oBACnC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;wBAClC,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,SAAS,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;4BACjD,OAAO,CAAC,cAAc,CACrB,CAAC,EACD,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvB,OAAO,CAAC,gBAAgB,EACxB,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAC3B,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAC3C,CAAC;wBACH,CAAC;oBACF,CAAC,CAAC,CAAC;gBACJ,CAAC,QAAQ,WAAW,EAAE;YACvB,CAAC;SACD,CAAC;KACF,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { benchmarkDuration, benchmarkIt } from \"@fluid-tools/benchmark\";\n\nimport { MergeTree } from \"../mergeTree.js\";\nimport { MergeTreeDeltaType } from \"../ops.js\";\nimport { TextSegment } from \"../textSegment.js\";\n\nfunction constructTree(numOfSegments: number): MergeTree {\n\tconst mergeTree = new MergeTree();\n\tfor (let i = 0; i < numOfSegments; i++) {\n\t\tmergeTree.insertSegments(\n\t\t\t0,\n\t\t\t[TextSegment.make(\"a\")],\n\t\t\tmergeTree.localPerspective,\n\t\t\t{ seq: i, clientId: 0 },\n\t\t\t{ op: { type: MergeTreeDeltaType.INSERT } },\n\t\t);\n\t}\n\treturn mergeTree;\n}\n\nconst TREE_SIZE: number = 7500;\n\ndescribe(\"MergeTree insertion\", () => {\n\tbenchmarkIt({\n\t\ttitle: \"insert into empty tree\",\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFn: () => {\n\t\t\t\tconst emptyTree = new MergeTree();\n\t\t\t\temptyTree.insertSegments(\n\t\t\t\t\t0,\n\t\t\t\t\t[TextSegment.make(\"a\")],\n\t\t\t\t\temptyTree.localPerspective,\n\t\t\t\t\t{ seq: 0, clientId: 0 },\n\t\t\t\t\t{ op: { type: MergeTreeDeltaType.INSERT } },\n\t\t\t\t);\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: \"insert at start of large tree\",\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tlet startTree = constructTree(TREE_SIZE);\n\t\t\t\tlet keepRunning: boolean;\n\t\t\t\tdo {\n\t\t\t\t\tstartTree = constructTree(TREE_SIZE);\n\t\t\t\t\tkeepRunning = state.timeBatch(() => {\n\t\t\t\t\t\tfor (let i = TREE_SIZE; i < TREE_SIZE + 25; i++) {\n\t\t\t\t\t\t\tstartTree.insertSegments(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t[TextSegment.make(\"a\")],\n\t\t\t\t\t\t\t\tstartTree.localPerspective,\n\t\t\t\t\t\t\t\t{ seq: i + 1, clientId: 0 },\n\t\t\t\t\t\t\t\t{ op: { type: MergeTreeDeltaType.INSERT } },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} while (keepRunning);\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: \"insert at middle of large tree\",\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tlet middleTree = constructTree(TREE_SIZE);\n\t\t\t\tlet keepRunning: boolean;\n\t\t\t\tdo {\n\t\t\t\t\tmiddleTree = constructTree(TREE_SIZE);\n\t\t\t\t\tkeepRunning = state.timeBatch(() => {\n\t\t\t\t\t\tfor (let i = TREE_SIZE; i < TREE_SIZE + 25; i++) {\n\t\t\t\t\t\t\tmiddleTree.insertSegments(\n\t\t\t\t\t\t\t\tTREE_SIZE / 2,\n\t\t\t\t\t\t\t\t[TextSegment.make(\"a\")],\n\t\t\t\t\t\t\t\tmiddleTree.localPerspective,\n\t\t\t\t\t\t\t\t{ seq: i + 1, clientId: 0 },\n\t\t\t\t\t\t\t\t{ op: { type: MergeTreeDeltaType.INSERT } },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} while (keepRunning);\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: \"insert at end of large tree\",\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tlet endTree = constructTree(TREE_SIZE);\n\t\t\t\tlet keepRunning: boolean;\n\t\t\t\tdo {\n\t\t\t\t\tendTree = constructTree(TREE_SIZE);\n\t\t\t\t\tkeepRunning = state.timeBatch(() => {\n\t\t\t\t\t\tfor (let i = TREE_SIZE; i < TREE_SIZE + 25; i++) {\n\t\t\t\t\t\t\tendTree.insertSegments(\n\t\t\t\t\t\t\t\ti,\n\t\t\t\t\t\t\t\t[TextSegment.make(\"a\")],\n\t\t\t\t\t\t\t\tendTree.localPerspective,\n\t\t\t\t\t\t\t\t{ seq: i + 1, clientId: 0 },\n\t\t\t\t\t\t\t\t{ op: { type: MergeTreeDeltaType.INSERT } },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} while (keepRunning);\n\t\t\t},\n\t\t}),\n\t});\n});\n"]}
|
|
@@ -2,56 +2,59 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { benchmarkDuration, benchmarkIt } from "@fluid-tools/benchmark";
|
|
6
6
|
import { MergeTree } from "../mergeTree.js";
|
|
7
7
|
import { MergeTreeDeltaType } from "../ops.js";
|
|
8
8
|
import { PriorPerspective } from "../perspective.js";
|
|
9
9
|
import { TextSegment } from "../textSegment.js";
|
|
10
10
|
describe("MergeTree partial lengths", () => {
|
|
11
|
-
const originalIncrementalUpdate = MergeTree.options.incrementalUpdate;
|
|
12
11
|
for (const incremental of [true, false]) {
|
|
13
|
-
|
|
14
|
-
type: BenchmarkType.Measurement,
|
|
12
|
+
benchmarkIt({
|
|
15
13
|
title: `incremental updates = ${incremental}`,
|
|
16
14
|
category: "partial lengths",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
15
|
+
...benchmarkDuration({
|
|
16
|
+
benchmarkFnCustom: async (state) => {
|
|
17
|
+
const originalIncrementalUpdate = MergeTree.options.incrementalUpdate;
|
|
18
|
+
MergeTree.options.incrementalUpdate = incremental;
|
|
19
|
+
try {
|
|
20
|
+
state.timeAllBatches(() => {
|
|
21
|
+
const mergeTree = new MergeTree();
|
|
22
|
+
const clientId = 0;
|
|
23
|
+
let i = 1;
|
|
24
|
+
for (; i < 1001; i++) {
|
|
25
|
+
const stamp = {
|
|
26
|
+
seq: i,
|
|
27
|
+
clientId,
|
|
28
|
+
};
|
|
29
|
+
mergeTree.insertSegments(0, [TextSegment.make("a")], new PriorPerspective(i, clientId), stamp, {
|
|
30
|
+
op: { type: MergeTreeDeltaType.INSERT },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
for (; i < 2001; i++) {
|
|
34
|
+
const stamp = {
|
|
35
|
+
seq: i,
|
|
36
|
+
clientId,
|
|
37
|
+
};
|
|
38
|
+
mergeTree.markRangeRemoved(i - 1001, i - 1000, new PriorPerspective(i, clientId), stamp, {
|
|
39
|
+
op: { type: MergeTreeDeltaType.REMOVE },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
for (; i < 3001; i++) {
|
|
43
|
+
const stamp = {
|
|
44
|
+
seq: i,
|
|
45
|
+
clientId,
|
|
46
|
+
};
|
|
47
|
+
mergeTree.insertSegments(0, [TextSegment.make("a")], new PriorPerspective(i, clientId), stamp, {
|
|
48
|
+
op: { type: MergeTreeDeltaType.INSERT },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
MergeTree.options.incrementalUpdate = originalIncrementalUpdate;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PartialLengths.perf.spec.js","sourceRoot":"","sources":["../../src/test/PartialLengths.perf.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PartialLengths.perf.spec.js","sourceRoot":"","sources":["../../src/test/PartialLengths.perf.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IAC1C,KAAK,MAAM,WAAW,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,WAAW,CAAC;YACX,KAAK,EAAE,yBAAyB,WAAW,EAAE;YAC7C,QAAQ,EAAE,iBAAiB;YAC3B,GAAG,iBAAiB,CAAC;gBACpB,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;oBAClC,MAAM,yBAAyB,GAAY,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC;oBAC/E,SAAS,CAAC,OAAO,CAAC,iBAAiB,GAAG,WAAW,CAAC;oBAClD,IAAI,CAAC;wBACJ,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE;4BACzB,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;4BAElC,MAAM,QAAQ,GAAG,CAAC,CAAC;4BACnB,IAAI,CAAC,GAAG,CAAC,CAAC;4BACV,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;gCACtB,MAAM,KAAK,GAAmB;oCAC7B,GAAG,EAAE,CAAC;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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { benchmarkDuration, benchmarkIt } from \"@fluid-tools/benchmark\";\n\nimport { MergeTree } from \"../mergeTree.js\";\nimport { MergeTreeDeltaType } from \"../ops.js\";\nimport { PriorPerspective } from \"../perspective.js\";\nimport type { OperationStamp } from \"../stamps.js\";\nimport { TextSegment } from \"../textSegment.js\";\n\ndescribe(\"MergeTree partial lengths\", () => {\n\tfor (const incremental of [true, false]) {\n\t\tbenchmarkIt({\n\t\t\ttitle: `incremental updates = ${incremental}`,\n\t\t\tcategory: \"partial lengths\",\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst originalIncrementalUpdate: boolean = MergeTree.options.incrementalUpdate;\n\t\t\t\t\tMergeTree.options.incrementalUpdate = incremental;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\t\tconst mergeTree = new MergeTree();\n\n\t\t\t\t\t\t\tconst clientId = 0;\n\t\t\t\t\t\t\tlet i = 1;\n\t\t\t\t\t\t\tfor (; i < 1001; i++) {\n\t\t\t\t\t\t\t\tconst stamp: OperationStamp = {\n\t\t\t\t\t\t\t\t\tseq: i,\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tmergeTree.insertSegments(\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t[TextSegment.make(\"a\")],\n\t\t\t\t\t\t\t\t\tnew PriorPerspective(i, clientId),\n\t\t\t\t\t\t\t\t\tstamp,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\top: { type: MergeTreeDeltaType.INSERT },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (; i < 2001; i++) {\n\t\t\t\t\t\t\t\tconst stamp: OperationStamp = {\n\t\t\t\t\t\t\t\t\tseq: i,\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tmergeTree.markRangeRemoved(\n\t\t\t\t\t\t\t\t\ti - 1001,\n\t\t\t\t\t\t\t\t\ti - 1000,\n\t\t\t\t\t\t\t\t\tnew PriorPerspective(i, clientId),\n\t\t\t\t\t\t\t\t\tstamp,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\top: { type: MergeTreeDeltaType.REMOVE },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (; i < 3001; i++) {\n\t\t\t\t\t\t\t\tconst stamp: OperationStamp = {\n\t\t\t\t\t\t\t\t\tseq: i,\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tmergeTree.insertSegments(\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t[TextSegment.make(\"a\")],\n\t\t\t\t\t\t\t\t\tnew PriorPerspective(i, clientId),\n\t\t\t\t\t\t\t\t\tstamp,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\top: { type: MergeTreeDeltaType.INSERT },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tMergeTree.options.incrementalUpdate = originalIncrementalUpdate;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t}\n});\n"]}
|
|
@@ -2,135 +2,140 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { benchmarkDuration, benchmarkIt } from "@fluid-tools/benchmark";
|
|
6
6
|
import { MergeTreeDeltaType } from "../ops.js";
|
|
7
7
|
import { PriorPerspective } from "../perspective.js";
|
|
8
8
|
import { appendToMergeTreeDeltaRevertibles, } from "../revertibles.js";
|
|
9
9
|
import { TestString, loadSnapshot } from "./snapshot.utils.js";
|
|
10
10
|
describe("MergeTree remove", () => {
|
|
11
|
-
|
|
12
|
-
benchmark({
|
|
13
|
-
type: BenchmarkType.Measurement,
|
|
11
|
+
benchmarkIt({
|
|
14
12
|
// baseline summary benchmark to compare to other remove tests. such a
|
|
15
13
|
// comparison should give a (rough) sense of overhead caused by summary
|
|
16
14
|
// loading
|
|
17
15
|
title: "baseline summary load",
|
|
18
16
|
category: "remove",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
...benchmarkDuration({
|
|
18
|
+
benchmarkFnCustom: async (state) => {
|
|
19
|
+
const str = new TestString("id", {});
|
|
20
|
+
for (let i = 0; i < 1000; i++) {
|
|
21
|
+
str.append("a", false);
|
|
22
|
+
}
|
|
23
|
+
str.applyPendingOps();
|
|
24
|
+
const summary = str.getSummary();
|
|
25
|
+
await state.timeAllBatchesAsync(async () => {
|
|
26
|
+
await loadSnapshot(summary);
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
30
|
});
|
|
31
|
-
|
|
32
|
-
type: BenchmarkType.Measurement,
|
|
31
|
+
benchmarkIt({
|
|
33
32
|
title: "remove large range of large tree",
|
|
34
33
|
category: "remove",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
for (let i = 0; i < 1000; i++) {
|
|
38
|
-
str.append("a", false);
|
|
39
|
-
}
|
|
40
|
-
str.applyPendingOps();
|
|
41
|
-
summary = str.getSummary();
|
|
42
|
-
},
|
|
43
|
-
benchmarkFnAsync: async () => {
|
|
44
|
-
const str = await loadSnapshot(summary);
|
|
45
|
-
const refSeq = 1000;
|
|
46
|
-
const clientId = 0;
|
|
47
|
-
str.mergeTree.markRangeRemoved(0, 1000, new PriorPerspective(refSeq, clientId), { seq: 1001, clientId }, { op: { type: MergeTreeDeltaType.REMOVE } });
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
for (const length of [10, 100, 1000]) {
|
|
51
|
-
benchmark({
|
|
52
|
-
type: BenchmarkType.Measurement,
|
|
53
|
-
title: `remove range of length ${length} from large tree with undo-redo`,
|
|
54
|
-
category: "remove",
|
|
55
|
-
before: () => {
|
|
34
|
+
...benchmarkDuration({
|
|
35
|
+
benchmarkFnCustom: async (state) => {
|
|
56
36
|
const str = new TestString("id", {});
|
|
57
|
-
for (let i = 0; i <
|
|
58
|
-
str.append("a",
|
|
59
|
-
str.appendMarker(true);
|
|
37
|
+
for (let i = 0; i < 1000; i++) {
|
|
38
|
+
str.append("a", false);
|
|
60
39
|
}
|
|
61
40
|
str.applyPendingOps();
|
|
62
|
-
summary = str.getSummary();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
appendToMergeTreeDeltaRevertibles(delta, revertibles);
|
|
41
|
+
const summary = str.getSummary();
|
|
42
|
+
await state.timeAllBatchesAsync(async () => {
|
|
43
|
+
const loadedStr = await loadSnapshot(summary);
|
|
44
|
+
const refSeq = 1000;
|
|
45
|
+
const clientId = 0;
|
|
46
|
+
loadedStr.mergeTree.markRangeRemoved(0, 1000, new PriorPerspective(refSeq, clientId), { seq: 1001, clientId }, { op: { type: MergeTreeDeltaType.REMOVE } });
|
|
69
47
|
});
|
|
70
|
-
const op = str.removeRangeLocal(0, length - 1);
|
|
71
|
-
str.applyMsg(str.makeOpMessage(op,
|
|
72
|
-
/* seq */ length + 1,
|
|
73
|
-
/* refSeq */ length, str.longClientId,
|
|
74
|
-
/* minSeq */ length));
|
|
75
48
|
},
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
for (const length of [10, 100, 1000]) {
|
|
52
|
+
benchmarkIt({
|
|
53
|
+
title: `remove range of length ${length} from large tree with undo-redo`,
|
|
54
|
+
category: "remove",
|
|
55
|
+
...benchmarkDuration({
|
|
56
|
+
benchmarkFnCustom: async (state) => {
|
|
57
|
+
const str = new TestString("id", {});
|
|
58
|
+
for (let i = 0; i < length / 2; i++) {
|
|
59
|
+
str.append("a", true);
|
|
60
|
+
str.appendMarker(true);
|
|
61
|
+
}
|
|
62
|
+
str.applyPendingOps();
|
|
63
|
+
const summary = str.getSummary();
|
|
64
|
+
await state.timeAllBatchesAsync(async () => {
|
|
65
|
+
const loadedStr = await loadSnapshot(summary);
|
|
66
|
+
const revertibles = [];
|
|
67
|
+
loadedStr.on("delta", (_op, delta) => {
|
|
68
|
+
appendToMergeTreeDeltaRevertibles(delta, revertibles);
|
|
69
|
+
});
|
|
70
|
+
const op = loadedStr.removeRangeLocal(0, length - 1);
|
|
71
|
+
loadedStr.applyMsg(loadedStr.makeOpMessage(op,
|
|
72
|
+
/* seq */ length + 1,
|
|
73
|
+
/* refSeq */ length, loadedStr.longClientId,
|
|
74
|
+
/* minSeq */ length));
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
|
-
|
|
79
|
-
type: BenchmarkType.Measurement,
|
|
80
|
+
benchmarkIt({
|
|
80
81
|
title: "remove start of large tree",
|
|
81
82
|
category: "remove",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
...benchmarkDuration({
|
|
84
|
+
benchmarkFnCustom: async (state) => {
|
|
85
|
+
const str = new TestString("id", {});
|
|
86
|
+
for (let i = 0; i < 1000; i++) {
|
|
87
|
+
str.append("a", false);
|
|
88
|
+
}
|
|
89
|
+
str.applyPendingOps();
|
|
90
|
+
const summary = str.getSummary();
|
|
91
|
+
await state.timeAllBatchesAsync(async () => {
|
|
92
|
+
const loadedStr = await loadSnapshot(summary);
|
|
93
|
+
const refSeq = 1000;
|
|
94
|
+
const clientId = 0;
|
|
95
|
+
loadedStr.mergeTree.markRangeRemoved(0, 1, new PriorPerspective(refSeq, clientId), { seq: 1001, clientId }, { op: { type: MergeTreeDeltaType.REMOVE } });
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
96
99
|
});
|
|
97
|
-
|
|
98
|
-
type: BenchmarkType.Measurement,
|
|
100
|
+
benchmarkIt({
|
|
99
101
|
title: "remove middle of large tree",
|
|
100
102
|
category: "remove",
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
103
|
+
...benchmarkDuration({
|
|
104
|
+
benchmarkFnCustom: async (state) => {
|
|
105
|
+
const str = new TestString("id", {});
|
|
106
|
+
for (let i = 0; i < 1000; i++) {
|
|
107
|
+
str.append("a", false);
|
|
108
|
+
}
|
|
109
|
+
str.applyPendingOps();
|
|
110
|
+
const summary = str.getSummary();
|
|
111
|
+
await state.timeAllBatchesAsync(async () => {
|
|
112
|
+
const loadedStr = await loadSnapshot(summary);
|
|
113
|
+
const refSeq = 1000;
|
|
114
|
+
const clientId = 0;
|
|
115
|
+
loadedStr.mergeTree.markRangeRemoved(499, 501, new PriorPerspective(refSeq, clientId), { seq: 1001, clientId }, { op: { type: MergeTreeDeltaType.REMOVE } });
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
115
119
|
});
|
|
116
|
-
|
|
117
|
-
type: BenchmarkType.Measurement,
|
|
120
|
+
benchmarkIt({
|
|
118
121
|
title: "remove end of large tree",
|
|
119
122
|
category: "remove",
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
...benchmarkDuration({
|
|
124
|
+
benchmarkFnCustom: async (state) => {
|
|
125
|
+
const str = new TestString("id", {});
|
|
126
|
+
for (let i = 0; i < 1000; i++) {
|
|
127
|
+
str.append("a", false);
|
|
128
|
+
}
|
|
129
|
+
str.applyPendingOps();
|
|
130
|
+
const summary = str.getSummary();
|
|
131
|
+
await state.timeAllBatchesAsync(async () => {
|
|
132
|
+
const loadedStr = await loadSnapshot(summary);
|
|
133
|
+
const refSeq = 1000;
|
|
134
|
+
const clientId = 0;
|
|
135
|
+
loadedStr.mergeTree.markRangeRemoved(999, 1000, new PriorPerspective(refSeq, clientId), { seq: 1001, clientId }, { op: { type: MergeTreeDeltaType.REMOVE } });
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
134
139
|
});
|
|
135
140
|
});
|
|
136
141
|
//# sourceMappingURL=Removal.perf.spec.js.map
|