diff --git a/.github/workflows/ci-benchmarks.yml b/.github/workflows/ci-benchmarks.yml new file mode 100644 index 00000000000..85513b80756 --- /dev/null +++ b/.github/workflows/ci-benchmarks.yml @@ -0,0 +1,102 @@ +name: Fast Element benchmark jobs + +on: [pull_request] + +jobs: + # If you'd like a message to appear in existing results comment that the + # benchmarks are current running and the shown results are out of date, run a + # job before the benchmarks with the initialize option set to true. + setup: + name: Setup Tachometer Reporting + runs-on: ubuntu-latest + steps: + - name: Initialize tachometer comment + uses: andrewiggins/tachometer-reporter-action@v2 + with: + initialize: true + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo '::set-output name=dir::$(yarn cache dir)' + + - name: Set up node_modules cache + uses: actions/cache@v2 + id: yarn-cache + with: + path: | + ${{ steps.yarn-cache-dir-path.outputs.dir }} + node_modules + */*/node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install package dependencies + run: yarn install --frozen-lockfile --ignore-scripts --prefer-offline + - name: Prepare workspaces + run: yarn prepare + + create10k: + name: Run create 10k items benchmark + needs: [setup] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: "16.x" + - run: yarn install --frozen-lockfile --ignore-scripts --prefer-offline + # Run benchmarks. Ensure each job's results file has a unique name + - name: Run tachometer + run: | + cd packages/utilities/fast-benchmarks + yarn install + yarn run benchmark:fast-element:create10k + + # Upload this benchmarks results + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: packages/utilities/fast-benchmarks/results/fast-element_test-create10k.json + + update10th: + name: Run update 10th element benchmark + needs: [setup] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: "16.x" + - name: Run tachometer and generate results file + run: | + cd packages/utilities/fast-benchmarks + yarn install + yarn run benchmark:fast-element:update10th + + # Upload this benchmarks results + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: packages/utilities/fast-benchmarks/results/fast-element_test-update10th.json + + report_results: + name: Report Results + needs: [create10k, update10th] + runs-on: ubuntu-latest + steps: + # Download the results artifact + - uses: actions/download-artifact@v2 + with: + name: results + path: packages/utilities/fast-benchmarks/results + + # Read all the results and post comment + - name: Report Tachometer Result + uses: andrewiggins/tachometer-reporter-action@v2 + with: + name: results + path: packages/utilities/fast-benchmarks/results/*.json diff --git a/change/fast-benchmarks-9a607d76-22aa-4cdd-bd1a-4b186cb44969.json b/change/fast-benchmarks-9a607d76-22aa-4cdd-bd1a-4b186cb44969.json new file mode 100644 index 00000000000..e52cc329136 --- /dev/null +++ b/change/fast-benchmarks-9a607d76-22aa-4cdd-bd1a-4b186cb44969.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "run workflow on any push", + "packageName": "fast-benchmarks", + "email": "email not defined", + "dependentChangeType": "patch" +} diff --git a/packages/utilities/fast-benchmarks/benchmarks/fast-element/test/index2.ts b/packages/utilities/fast-benchmarks/benchmarks/fast-element/localTest/index2.ts similarity index 100% rename from packages/utilities/fast-benchmarks/benchmarks/fast-element/test/index2.ts rename to packages/utilities/fast-benchmarks/benchmarks/fast-element/localTest/index2.ts diff --git a/packages/utilities/fast-benchmarks/benchmarks/fast-element/test/index.ts b/packages/utilities/fast-benchmarks/benchmarks/fast-element/test/index.ts index 5b13d2e7a5e..fe252cb59f1 100644 --- a/packages/utilities/fast-benchmarks/benchmarks/fast-element/test/index.ts +++ b/packages/utilities/fast-benchmarks/benchmarks/fast-element/test/index.ts @@ -13,7 +13,7 @@ import { data, RandomItem } from "../../../utils/index.js"; name: "x-item", template: html`
- ${x => x.value} + ${(x: XItem) => x.value}
`, styles: css` @@ -36,7 +36,7 @@ class XItem extends FASTElement { ${repeat( x => x.items, html` - + ` )} diff --git a/packages/utilities/fast-benchmarks/package.json b/packages/utilities/fast-benchmarks/package.json index 4ebbc883d62..189274e3f47 100644 --- a/packages/utilities/fast-benchmarks/package.json +++ b/packages/utilities/fast-benchmarks/package.json @@ -1,27 +1,28 @@ { "name": "fast-benchmarks", "version": "1.0.0", - "description": "", + "description": "utility library benchmarking for FAST libraries", "type": "module", "scripts": { "build": "tsc && tsc --build", "benchmark": "node scripts/index.js", "help": "node ./scripts/index.js --help", - "benchmark:binding": "tach --config benchmarks/fast-element/binding/tachometer.json", - "debug:binding": "tach --config fast-element/binding/tachometer.json --manual" + "benchmark:binding": "tach --config examples/fast-element/binding/tachometer.json", + "debug:binding": "tach --config fast-element/binding/tachometer.json --manual", + "benchmark:fast-element:create10k": "yarn run benchmark --library=fast-element --benchmark=test --versions 1.6.0 1.10.1 --operations=create10k", + "benchmark:fast-element:update10th": "yarn run benchmark --library=fast-element --benchmark=test --versions 1.6.0 1.10.1 --operations=update10th" }, "author": "Microsoft", "license": "ISC", "dependencies": { - "@microsoft/fast-element": "file:../../web-components/fast-element", - "@microsoft/fast-foundation": "^2.45.0", + "@microsoft/fast-element": "1.10.1", "tachometer": "^0.5.10" }, "devDependencies": { "chalk": "^5.0.1", - "chromedriver": "^99.0.0", + "chromedriver": "^101.0.0", "commander": "^9.2.0", "cross-spawn": "^7.0.3", - "typescript": "^4.3.5" + "typescript": "^4.6.2" } } diff --git a/packages/utilities/fast-benchmarks/results/fast-element_test-create10k.json b/packages/utilities/fast-benchmarks/results/fast-element_test-create10k.json new file mode 100644 index 00000000000..c7edebfa14d --- /dev/null +++ b/packages/utilities/fast-benchmarks/results/fast-element_test-create10k.json @@ -0,0 +1,372 @@ +{ + "benchmarks": [ + { + "name": "test-create10k [create10k]", + "bytesSent": 117471, + "version": "1.6.0", + "measurement": { + "name": "create10k", + "mode": "performance", + "entryName": "create10k" + }, + "browser": { + "name": "chrome", + "headless": true, + "windowSize": { + "width": 1024, + "height": 768 + }, + "addArguments": [ + "--js-flags=--expose-gc", + "--enable-precise-memory-info" + ], + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/101.0.4951.64 Safari/537.36" + }, + "mean": { + "low": 667.116031388494, + "high": 714.5573019384816 + }, + "differences": [ + null, + { + "absolute": { + "low": 653.0759359961918, + "high": 700.5172071307837 + }, + "percentChange": { + "low": 4651.5014603386935, + "high": 4989.410039804746 + } + }, + { + "absolute": { + "low": -50.72704777496968, + "high": 26.08038109916363 + }, + "percentChange": { + "low": -7.155153898621699, + "high": 3.6500246711688735 + } + }, + { + "absolute": { + "low": 653.0726697082875, + "high": 700.5139408853547 + }, + "percentChange": { + "low": 4650.3959716472755, + "high": 4988.226686077082 + } + } + ], + "samples": [ + 663.2999999821186, + 720.5, + 718.9000000059605, + 657.4000000059605, + 637.5, + 636.5, + 625.2999999821186, + 645.4000000059605, + 631.0999999940395, + 627.0999999940395, + 642.8000000119209, + 617.8000000119209, + 623, + 622.5999999940395, + 680.5, + 659.9000000059605, + 686.8999999761581, + 699.0999999940395, + 818.8000000119209, + 666.5999999940395, + 737.0999999940395, + 672, + 672.3000000119209, + 683.1999999880791, + 760.5, + 785.1999999880791, + 780.5999999940395, + 727.5999999940395, + 774.8999999761581, + 850.6999999880791 + ] + }, + { + "name": "test-create10k [usedJSHeapSize]", + "bytesSent": 117471, + "version": "1.6.0", + "measurement": { + "name": "usedJSHeapSize", + "mode": "expression", + "expression": "window.usedJSHeapSize" + }, + "browser": { + "name": "chrome", + "headless": true, + "windowSize": { + "width": 1024, + "height": 768 + }, + "addArguments": [ + "--js-flags=--expose-gc", + "--enable-precise-memory-info" + ], + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/101.0.4951.64 Safari/537.36" + }, + "mean": { + "low": 14.036371232372135, + "high": 14.043818967627866 + }, + "differences": [ + { + "absolute": { + "low": -700.5172071307837, + "high": -653.0759359961918 + }, + "percentChange": { + "low": -98.03745236827837, + "high": -97.89788349980488 + } + }, + null, + { + "absolute": { + "low": -719.3221690314468, + "high": -658.9176407713347 + }, + "percentChange": { + "low": -98.0890507522181, + "high": -97.91752098110796 + } + }, + { + "absolute": { + "low": -0.008627415662692726, + "high": 0.002094882329361468 + }, + "percentChange": { + "low": -0.06142952644098684, + "high": 0.014912648018724743 + } + } + ], + "samples": [ + 14.037468, + 14.033924, + 14.025496, + 14.049131, + 14.043269, + 14.057676, + 14.026902, + 14.046617, + 14.027228, + 14.049136, + 14.042532, + 14.048395, + 14.026427, + 14.050542, + 14.028394, + 14.028419, + 14.024644, + 14.047864, + 14.03684, + 14.048622, + 14.049716, + 14.046062, + 14.050546, + 14.046413, + 14.044127, + 14.041914, + 14.046024, + 14.021654, + 14.04379, + 14.033081 + ] + }, + { + "name": "test-create10k [create10k]", + "bytesSent": 119449, + "version": "1.10.1", + "measurement": { + "name": "create10k", + "mode": "performance", + "entryName": "create10k" + }, + "browser": { + "name": "chrome", + "headless": true, + "windowSize": { + "width": 1024, + "height": 768 + }, + "addArguments": [ + "--js-flags=--expose-gc", + "--enable-precise-memory-info" + ], + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/101.0.4951.64 Safari/537.36" + }, + "mean": { + "low": 672.9577361009067, + "high": 733.3622639018749 + }, + "differences": [ + { + "absolute": { + "low": -26.08038109916363, + "high": 50.72704777496968 + }, + "percentChange": { + "low": -3.8132267994542572, + "high": 7.380881480385031 + } + }, + { + "absolute": { + "low": 658.9176407713347, + "high": 719.3221690314468 + }, + "percentChange": { + "low": 4693.109701128759, + "high": 5123.34666890524 + } + }, + null, + { + "absolute": { + "low": 658.9143744879882, + "high": 719.3189027814601 + }, + "percentChange": { + "low": 4691.994602761273, + "high": 5122.132095856794 + } + } + ], + "samples": [ + 717.3000000119209, + 657.0999999940395, + 672.9000000059605, + 671.2000000178814, + 646.4000000059605, + 653.5, + 636.9000000059605, + 636.8000000119209, + 656.7000000178814, + 626.0999999940395, + 631.2999999821186, + 626.2999999821186, + 623.8000000119209, + 630.1999999880791, + 656.5, + 718.3999999761581, + 947.5, + 915.0999999940395, + 707.1000000238419, + 678.9000000059605, + 725.6999999880791, + 696, + 709.2000000178814, + 757.2000000178814, + 724.9000000059605, + 842.9000000059605, + 716.0999999940395, + 796.6999999880791, + 714.1999999880791, + 701.9000000059605 + ] + }, + { + "name": "test-create10k [usedJSHeapSize]", + "bytesSent": 119449, + "version": "1.10.1", + "measurement": { + "name": "usedJSHeapSize", + "mode": "expression", + "expression": "window.usedJSHeapSize" + }, + "browser": { + "name": "chrome", + "headless": true, + "windowSize": { + "width": 1024, + "height": 768 + }, + "addArguments": [ + "--js-flags=--expose-gc", + "--enable-precise-memory-info" + ], + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/101.0.4951.64 Safari/537.36" + }, + "mean": { + "low": 14.039504589715929, + "high": 14.047218143617403 + }, + "differences": [ + { + "absolute": { + "low": -700.5139408853547, + "high": -653.0726697082875 + }, + "percentChange": { + "low": -98.03699595439626, + "high": -97.89739431631956 + } + }, + { + "absolute": { + "low": -0.002094882329361468, + "high": 0.008627415662692726 + }, + "percentChange": { + "low": -0.014924999405122628, + "high": 0.06145269944421466 + } + }, + { + "absolute": { + "low": -719.3189027814601, + "high": -658.9143744879882 + }, + "percentChange": { + "low": -98.08860630986203, + "high": -97.91703639830145 + } + }, + null + ], + "samples": [ + 14.048473, + 14.047763, + 14.050955, + 14.055272, + 14.031051, + 14.04989, + 14.053042, + 14.037029, + 14.032756, + 14.050906, + 14.029424, + 14.030585, + 14.039553, + 14.051243, + 14.048806, + 14.051513, + 14.049451, + 14.051954, + 14.031287, + 14.051342, + 14.050882, + 14.035403, + 14.029567, + 14.047404, + 14.043494, + 14.015721, + 14.051628, + 14.031302, + 14.046023, + 14.057122 + ] + } + ] +} diff --git a/packages/utilities/fast-benchmarks/results/fast-element_test-update10th.json b/packages/utilities/fast-benchmarks/results/fast-element_test-update10th.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utilities/fast-benchmarks/results/result.json b/packages/utilities/fast-benchmarks/results/result.json new file mode 100644 index 00000000000..ae10e971ddf --- /dev/null +++ b/packages/utilities/fast-benchmarks/results/result.json @@ -0,0 +1,148 @@ +{ + "benchmarks": [ + { + "name": "my-benchmark-createDelete5x-memory", + "bytesSent": 2462, + "version": "1.8.0", + "measurement": { + "name": "usedJSHeapSize", + "mode": "expression", + "expression": "window.usedJSHeapSize" + }, + "browser": { + "name": "chrome", + "headless": true, + "windowSize": { + "width": 1024, + "height": 768 + }, + "addArguments": [ + "--js-flags=--expose-gc", + "--enable-precise-memory-info" + ], + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/101.0.4951.64 Safari/537.36" + }, + "mean": { + "low": 2.798855688350844, + "high": 2.8072279116491567 + }, + "differences": [ + null, + { + "absolute": { + "low": -0.006109477419492123, + "high": 0.006640144086160134 + }, + "percentChange": { + "low": -0.21799172212870524, + "high": 0.2369253286071103 + } + } + ], + "samples": [ + 2.808279, + 2.801631, + 2.802211, + 2.808047, + 2.810679, + 2.808827, + 2.804287, + 2.812383, + 2.781763, + 2.810795, + 2.789987, + 2.794883, + 2.811811, + 2.783375, + 2.777799, + 2.806811, + 2.808839, + 2.809983, + 2.812307, + 2.808351, + 2.779391, + 2.808427, + 2.812959, + 2.810375, + 2.811219, + 2.811399, + 2.797831, + 2.809859, + 2.811671, + 2.785075 + ] + }, + { + "name": "my-benchmark-createDelete5x-memory", + "bytesSent": 2462, + "version": "1.9.0", + "measurement": { + "name": "usedJSHeapSize", + "mode": "expression", + "expression": "window.usedJSHeapSize" + }, + "browser": { + "name": "chrome", + "headless": true, + "windowSize": { + "width": 1024, + "height": 768 + }, + "addArguments": [ + "--js-flags=--expose-gc", + "--enable-precise-memory-info" + ], + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/101.0.4951.64 Safari/537.36" + }, + "mean": { + "low": 2.7979686936484023, + "high": 2.8075842396849304 + }, + "differences": [ + { + "absolute": { + "low": -0.006640144086160134, + "high": 0.006109477419492123 + }, + "percentChange": { + "low": -0.23688137250091656, + "high": 0.2179495582601153 + } + }, + null + ], + "samples": [ + 2.809623, + 2.810455, + 2.811059, + 2.810767, + 2.805663, + 2.775991, + 2.811427, + 2.812123, + 2.778291, + 2.812443, + 2.792823, + 2.775027, + 2.811891, + 2.811607, + 2.810131, + 2.810563, + 2.809639, + 2.809727, + 2.811411, + 2.805347, + 2.810707, + 2.805539, + 2.785347, + 2.783935, + 2.776715, + 2.811763, + 2.812499, + 2.807943, + 2.796287, + 2.806551 + ] + } + ] +} diff --git a/packages/utilities/fast-benchmarks/scripts/index.js b/packages/utilities/fast-benchmarks/scripts/index.js index 286a48a672b..3a514fc6790 100644 --- a/packages/utilities/fast-benchmarks/scripts/index.js +++ b/packages/utilities/fast-benchmarks/scripts/index.js @@ -73,17 +73,23 @@ async function buildBenchmark(configPath) { * @param {string} configPath * @returns {Promise} */ -async function runBenchmark(configPaths) { +async function runBenchmark(configPaths, pathNames) { const promises = []; for (let i = 0; i < configPaths.length; i++) { const configPath = configPaths[i]; + const pathName = pathNames[i]; const res = new Promise((resolve, reject) => { - const args = ["tach", "--config", configPath]; + const args = [ + "tach", + "--config", + configPath, + `--json-file=results/${pathName}.json`, + ]; const child = spawn("npx", args, { stdio: "inherit" }); child.on("close", code => { if (code !== 0) { reject({ - command: `npx tach --config ${configPath}`, + command: `npx tach --config ${configPath} --json-file=results/${options.benchmark}/${pathName}.json`, }); return; } @@ -108,9 +114,11 @@ async function runBenchmark(configPaths) { const run = async () => { try { await checkNpmRegistryIsAvailable(); - const { tsConfigPath, tachoConfigPaths } = await generateTemplates(options); + const { tsConfigPath, tachoConfigPaths, pathNames } = await generateTemplates( + options + ); await buildBenchmark(tsConfigPath); - await runBenchmark(tachoConfigPaths); + await runBenchmark(tachoConfigPaths, pathNames); } catch (error) { return error; } diff --git a/packages/utilities/fast-benchmarks/scripts/template.js b/packages/utilities/fast-benchmarks/scripts/template.js index 9f8d6c4301a..da5d669f70e 100644 --- a/packages/utilities/fast-benchmarks/scripts/template.js +++ b/packages/utilities/fast-benchmarks/scripts/template.js @@ -179,16 +179,22 @@ async function generateBenchmarks( /** @type {ConfigFile["benchmarks"]} */ const benchmarks = []; - const memoryBenchmarks = []; + // const memoryBenchmarks = []; const browser = { name: "chrome", headless: true, + addArguments: ["--js-flags=--expose-gc", "--enable-precise-memory-info"], }; const measurement = [ { mode: "performance", entryName: operation, }, + { + name: "usedJSHeapSize", + mode: "expression", + expression: "window.usedJSHeapSize", + }, ]; versions.forEach(version => { @@ -241,29 +247,28 @@ async function generateBenchmarks( } //adjust some settings to separately report memory benchmark results - const memoryBench = JSON.parse(JSON.stringify(bench)); - const memoryMeasurement = [ - { - name: "usedJSHeapSize", - mode: "expression", - expression: "window.usedJSHeapSize", - }, - ]; - memoryBench.name = `${name}-memory`; - memoryBench.measurement = memoryMeasurement; - memoryBench.browser.addArguments = [ - "--js-flags=--expose-gc", - "--enable-precise-memory-info", - ]; - memoryBenchmarks.push(memoryBench); + // const memoryBench = JSON.parse(JSON.stringify(bench)); + // const memoryMeasurement = [ + // { + // name: "usedJSHeapSize", + // mode: "expression", + // expression: "window.usedJSHeapSize", + // }, + // ]; + // memoryBench.name = `${name}-memory`; + // memoryBench.measurement = memoryMeasurement; + // memoryBench.browser.addArguments = [ + // "--js-flags=--expose-gc", + // "--enable-precise-memory-info", + // ]; + // memoryBenchmarks.push(memoryBench); if (!memory) benchmarks.push(bench); }); - tachoData[`${operation}-memory`] = memoryBenchmarks; + // tachoData[`${operation}-memory`] = memoryBenchmarks; if (!memory) tachoData[operation] = benchmarks; }); - return tachoData; } @@ -282,11 +287,12 @@ async function generateConfig(fileName, benchmarksHash) { // Tachometer default is 50, but locally let's only do 10 sampleSize: 30, // Tachometer default is 3 minutes, but let's shrink it to 1 here to save some - timeout: 1, + timeout: 0, autoSampleConditions: ["0%", "10%"], }; const pathsPromises = []; + const pathNames = []; for (const benchmark in benchmarksHash) { const config = { $schema: TACH_SCHEMA, @@ -294,17 +300,14 @@ async function generateConfig(fileName, benchmarksHash) { benchmarks: benchmarksHash[benchmark], }; - const path = await writeConfig( - `${fileName}-${benchmark}` + ".config", - config, - ".json", - "dist" - ); + const name = `${fileName}-${benchmark}`; + const path = await writeConfig(`${name}.config`, config, ".json", "dist"); + pathNames.push(name); pathsPromises.push(path); } /** @type {ConfigFile[]} promises resolves to array of config file paths*/ - return await Promise.all(pathsPromises); + return [await Promise.all(pathsPromises), pathNames]; } catch (error) { console.log(errMessage(error)); } @@ -344,10 +347,14 @@ export async function generateTemplates(options) { operationProps, localProps ); - const tachoConfigPaths = await generateConfig(fileName, benchmarksHash); + const [tachoConfigPaths, pathNames] = await generateConfig( + fileName, + benchmarksHash + ); return { tsConfigPath, tachoConfigPaths, + pathNames, }; } catch (error) { console.log(errMessage(error)); diff --git a/packages/utilities/fast-benchmarks/utils/index.d.ts b/packages/utilities/fast-benchmarks/utils/index.d.ts new file mode 100644 index 00000000000..8249a7cd1f3 --- /dev/null +++ b/packages/utilities/fast-benchmarks/utils/index.d.ts @@ -0,0 +1,27 @@ +export declare const _random: (max: number) => number; +export declare const adjectives: string[]; +export declare const colours: string[]; +export declare const nouns: string[]; +export declare class RandomItem { + readonly id: number; + label: string; + constructor(id: number); +} +export declare const data: RandomItem[]; +export declare const destroy: (container: { + innerHTML: string; +}) => void; +export declare const getTestStartName: (name: any) => string; +export declare const updateComplete: () => Promise; +declare global { + interface Window { + gc: () => void; + usedJSHeapSize: number; + } + interface Performance { + memory: { + usedJSHeapSize: number; + }; + } +} +export declare function measureMemory(): void; diff --git a/packages/utilities/fast-benchmarks/utils/index.js b/packages/utilities/fast-benchmarks/utils/index.js new file mode 100644 index 00000000000..30e412464ca --- /dev/null +++ b/packages/utilities/fast-benchmarks/utils/index.js @@ -0,0 +1,94 @@ +export const _random = (max) => { + return Math.round(Math.random() * 1000) % max; +}; +//generate 10k, pass this value in +const itemCount = 10000; +let id = 0; +export const adjectives = [ + "pretty", + "large", + "big", + "small", + "tall", + "short", + "long", + "handsome", + "plain", + "quaint", + "clean", + "elegant", + "easy", + "angry", + "crazy", + "helpful", + "mushy", + "odd", + "unsightly", + "adorable", + "important", + "inexpensive", + "cheap", + "expensive", + "fancy", +]; +export const colours = [ + "red", + "yellow", + "blue", + "green", + "pink", + "brown", + "purple", + "brown", + "white", + "black", + "orange", +]; +export const nouns = [ + "table", + "chair", + "house", + "bbq", + "desk", + "car", + "pony", + "cookie", + "sandwich", + "burger", + "pizza", + "mouse", + "keyboard", +]; +export class RandomItem { + constructor(id) { + this.id = id; + this.label = + adjectives[_random(adjectives.length)] + + " " + + colours[_random(colours.length)] + + " " + + nouns[_random(nouns.length)]; + } +} +function generateData(count) { + const data = []; + for (let i = 0; i < count; i++) { + data.push(new RandomItem(++id)); + } + return data; +} +export const data = generateData(itemCount); +export const destroy = (container) => { + container.innerHTML = ""; +}; +export const getTestStartName = (name) => `${name}-start`; +export const updateComplete = () => new Promise(r => requestAnimationFrame(r)); +export function measureMemory() { + if (window && performance && performance.memory) { + // Report results in MBs\ + window.usedJSHeapSize = performance.memory.usedJSHeapSize / 1e6; + } + else { + window.usedJSHeapSize = 0; + } +} diff --git a/yarn.lock b/yarn.lock index 766f4833037..efc4ba67179 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3633,23 +3633,10 @@ "@microsoft/fast-jss-utilities" "^4.8.0" "@microsoft/fast-web-utilities" "^4.6.0" -"@microsoft/fast-element@^1.10.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@microsoft/fast-element/-/fast-element-1.10.0.tgz#a14d498e98a8fc6a80efab0013577db0f7ba4aae" - integrity sha512-z68APaW2CehGoL3iktXl9H/Pkn0PB6HLsG1sN0/2fS0XpBFjT3+teWdmTEs92FmSXdOeE2MzSy8nvPmJ9sy3xQ== - -"@microsoft/fast-element@file:packages/web-components/fast-element": - version "1.9.0" - -"@microsoft/fast-foundation@^2.45.0": - version "2.45.0" - resolved "https://registry.yarnpkg.com/@microsoft/fast-foundation/-/fast-foundation-2.45.0.tgz#49b859f4a74827e9754bce1bbb8e12bc80bc48ef" - integrity sha512-j8qQ6yW64pCH9seijG9HoOP9i5n9e3xZMOOczgAdOqurxUaEAqmxp1Rbf7MH89kA87LO5MygP22PKWFDtHD1+g== - dependencies: - "@microsoft/fast-element" "^1.10.0" - "@microsoft/fast-web-utilities" "^5.4.0" - tabbable "^5.2.0" - tslib "^1.13.0" +"@microsoft/fast-element@1.10.1": + version "1.10.1" + resolved "https://registry.yarnpkg.com/@microsoft/fast-element/-/fast-element-1.10.1.tgz#2ca442a4a8d15f3fd796795a370e3a1bc9bd2738" + integrity sha512-cq+vBBa8JCuAhsFEwHM9386YolYu9pNb1sBodp69RqWuaU56ElC60dC3aQWuOKqAMNoQqtCHPh0RQTvVBegSyw== "@microsoft/fast-jss-manager-react@^4.8.0": version "4.8.0" @@ -3742,13 +3729,6 @@ dependencies: exenv-es6 "^1.0.0" -"@microsoft/fast-web-utilities@^5.4.0": - version "5.4.0" - resolved "https://registry.yarnpkg.com/@microsoft/fast-web-utilities/-/fast-web-utilities-5.4.0.tgz#bb9bc548ae39224c550d2637d1d33fd9ffc6db79" - integrity sha512-bXgwsqbj2vNs34rTPdeSomiKG/Enotill+2ImOoF7MOU+GasQGpL1ksEUYSou616327Rh9wVMqRE6EGiSSMFwQ== - dependencies: - exenv-es6 "^1.1.1" - "@microsoft/tsdoc-config@^0.13.4": version "0.13.9" resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.13.9.tgz#d8c8e8ab79ca11dc14838090c463905ae4c1a22d" @@ -8361,10 +8341,10 @@ chrome-trace-event@^1.0.2: dependencies: tslib "^1.9.0" -chromedriver@^99.0.0: - version "99.0.0" - resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-99.0.0.tgz#fbfcc7e74991dd50962e7dd456d78eaf49f56774" - integrity sha512-pyB+5LuyZdb7EBPL3i5D5yucZUD+SlkdiUtmpjaEnLd9zAXp+SvD/hP5xF4l/ZmWvUo/1ZLxAI1YBdhazGTpgA== +chromedriver@^101.0.0: + version "101.0.0" + resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-101.0.0.tgz#ad19003008dd5df1770a1ad96059a9c5fe78e365" + integrity sha512-LkkWxy6KM/0YdJS8qBeg5vfkTZTRamhBfOttb4oic4echDgWvCU1E8QcBbUBOHqZpSrYMyi7WMKmKMhXFUaZ+w== dependencies: "@testim/chrome-version" "^1.1.2" axios "^0.24.0" @@ -24947,7 +24927,7 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.8.3, typescript@^3.9.0, typescript@^4.3.5, typescript@~3.7.2, "typescript@~3.9.0 || ~4.3.5", typescript@~4.3.2, typescript@~4.5.2: +typescript@^3.8.3, typescript@^3.9.0, typescript@^4.6.2, typescript@~3.7.2, "typescript@~3.9.0 || ~4.3.5", typescript@~4.3.2, typescript@~4.5.2: version "3.9.7" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==