diff --git a/packages/dds/tree/src/test/simple-tree/simpleTree.bench.ts b/packages/dds/tree/src/test/simple-tree/simpleTree.bench.ts index 1a68c553c874..7b1899ae8db3 100644 --- a/packages/dds/tree/src/test/simple-tree/simpleTree.bench.ts +++ b/packages/dds/tree/src/test/simple-tree/simpleTree.bench.ts @@ -5,12 +5,7 @@ import { strict as assert, fail } from "node:assert"; -import { - BenchmarkType, - benchmark, - isInPerformanceTestingMode, - type BenchmarkTimer, -} from "@fluid-tools/benchmark"; +import { BenchmarkType, benchmark, isInPerformanceTestingMode } from "@fluid-tools/benchmark"; import { type DeepTreeNode, generateDeepSimpleTree, @@ -122,26 +117,18 @@ describe("SimpleTree benchmarks", () => { assert.equal(readNumber, expectedValue); }, }); - + let flexTree: RootNode | undefined; benchmark({ type: BenchmarkType.Measurement, title: `${title} (flex node)`, - benchmarkFnCustom: async (state: BenchmarkTimer) => { - const flexTree = flexNodeInitFunction(); - - let duration: number; - do { - let counter = state.iterationsPerBatch; - const before = state.timer.now(); - while (counter--) { - readNumber = treeReadingFunction(flexTree); - } - const after = state.timer.now(); - - assert.equal(readNumber, expectedValue); - - duration = state.timer.toSeconds(before, after); - } while (state.recordBatch(duration)); + before: () => { + flexTree = flexNodeInitFunction(); + }, + benchmarkFn: () => { + readNumber = treeReadingFunction(flexTree ?? fail("Expected flexTree to be set")); + }, + after: () => { + assert.equal(readNumber, expectedValue); }, }); }