"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 testUtils_js_1 = require("./testUtils.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();
                let i = 1;
                for (; i < 1001; i++) {
                    (0, testUtils_js_1.insertText)({
                        mergeTree,
                        pos: 0,
                        refSeq: i,
                        clientId: 0,
                        seq: i,
                        text: "a",
                        props: undefined,
                        opArgs: { op: { type: ops_js_1.MergeTreeDeltaType.INSERT } },
                    });
                }
                for (; i < 2001; i++) {
                    (0, testUtils_js_1.markRangeRemoved)({
                        mergeTree,
                        start: i - 1001,
                        end: i - 1000,
                        refSeq: i,
                        clientId: 0,
                        seq: i,
                        opArgs: { op: { type: ops_js_1.MergeTreeDeltaType.REMOVE } },
                        overwrite: false,
                    });
                }
                for (; i < 3001; i++) {
                    (0, testUtils_js_1.insertText)({
                        mergeTree,
                        pos: 0,
                        refSeq: i,
                        clientId: 0,
                        seq: i,
                        text: "a",
                        props: undefined,
                        opArgs: { op: { type: ops_js_1.MergeTreeDeltaType.INSERT } },
                    });
                }
            },
            after: () => {
                mergeTree_js_1.MergeTree.options.incrementalUpdate = originalIncrementalUpdate;
            },
        });
    }
});
//# sourceMappingURL=PartialLengths.perf.spec.js.map