Skip to content

Commit

Permalink
Tree: speed up correctness mode for perf tests (#11334)
Browse files Browse the repository at this point in the history
Co-authored-by: Craig Macomber <[email protected]>
  • Loading branch information
CraigMacomber and Craig Macomber authored Jul 28, 2022
1 parent 96b92b0 commit 68f3b4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/dds/tree/src/test/domains/json/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Source = () => number;
* Generates a Jsonable tree with statistical similarities to 'canada.json':
* https://github.com/serde-rs/json-benchmark/tree/master/data
*/
export function generateCanada(rnd: Source) {
export function generateCanada(rnd: Source, tinyVersion = false) {
// Map uniform distribution in the range [0..1) to a uniform distribution
// in the range [min, max).
const uniform = (source: Source, min: number, max: number) =>
Expand Down Expand Up @@ -44,7 +44,7 @@ export function generateCanada(rnd: Source) {
let last_y = 43;

// The geometry of 'canada.json' is encoded as 480 segments of varying length.
const segmentLengths = [
const segmentLengths = tinyVersion ? [2, 10] : [
14, 33, 18, 23, 10, 28, 9, 28, 279, 221, 11, 86, 28, 19, 26, 23, 24, 38, 24, 9, 30, 20, 27, 21, 19, 25, 24, 20,
19, 18, 34, 19, 28, 12, 38, 30, 91, 17, 23, 28, 22, 24, 19, 44, 21, 19, 21, 24, 21, 24, 15, 20, 28, 18, 474,
17, 19, 12, 12, 1436, 31, 27, 26, 40, 21, 20, 27, 21, 19, 18, 24, 20, 65, 27, 36, 21, 27, 28, 24, 17, 20, 17,
Expand Down
5 changes: 3 additions & 2 deletions packages/dds/tree/src/test/domains/json/jsonCursor.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { strict as assert } from "assert";
import { benchmark, BenchmarkType } from "@fluid-tools/benchmark";
import { benchmark, BenchmarkType, isInPerformanceTestingMode } from "@fluid-tools/benchmark";
import { Jsonable } from "@fluidframework/datastore-definitions";
import { default as Random } from "random-js";
import { buildForest, ITreeCursor, jsonableTreeFromCursor, TextCursor } from "../../..";
Expand Down Expand Up @@ -107,7 +107,8 @@ function bench(name: string, getJson: () => any) {
}
}

const canada = generateCanada(makeRng("canada"));
// Make a test dataset, but only make it large in performance testing mode.
const canada = generateCanada(makeRng("canada"), !isInPerformanceTestingMode);

describe("ITreeCursor", () => {
bench("canada", () => canada);
Expand Down

0 comments on commit 68f3b4b

Please sign in to comment.