"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
const benchmark_1 = require("@fluid-tools/benchmark");
const mergeTree_js_1 = require("../mergeTree.js");
const ops_js_1 = require("../ops.js");
const perspective_js_1 = require("../perspective.js");
const textSegment_js_1 = require("../textSegment.js");
describe("MergeTree partial lengths", () => {
    const originalIncrementalUpdate = mergeTree_js_1.MergeTree.options.incrementalUpdate;
    for (const incremental of [true, false]) {
        (0, benchmark_1.benchmark)({
            type: benchmark_1.BenchmarkType.Measurement,
            title: `incremental updates = ${incremental}`,
            category: "partial lengths",
            before: () => {
                mergeTree_js_1.MergeTree.options.incrementalUpdate = incremental;
            },
            benchmarkFn: () => {
                const mergeTree = new mergeTree_js_1.MergeTree();
                const clientId = 0;
                let i = 1;
                for (; i < 1001; i++) {
                    const stamp = {
                        seq: i,
                        clientId,
                    };
                    mergeTree.insertSegments(0, [textSegment_js_1.TextSegment.make("a")], new perspective_js_1.PriorPerspective(i, clientId), stamp, {
                        op: { type: ops_js_1.MergeTreeDeltaType.INSERT },
                    });
                }
                for (; i < 2001; i++) {
                    const stamp = {
                        seq: i,
                        clientId,
                    };
                    mergeTree.markRangeRemoved(i - 1001, i - 1000, new perspective_js_1.PriorPerspective(i, clientId), stamp, {
                        op: { type: ops_js_1.MergeTreeDeltaType.REMOVE },
                    });
                }
                for (; i < 3001; i++) {
                    const stamp = {
                        seq: i,
                        clientId,
                    };
                    mergeTree.insertSegments(0, [textSegment_js_1.TextSegment.make("a")], new perspective_js_1.PriorPerspective(i, clientId), stamp, {
                        op: { type: ops_js_1.MergeTreeDeltaType.INSERT },
                    });
                }
            },
            after: () => {
                mergeTree_js_1.MergeTree.options.incrementalUpdate = originalIncrementalUpdate;
            },
        });
    }
});
//# sourceMappingURL=PartialLengths.perf.spec.js.map