From ebae5e76dfad5290220d5c56f4a62d19bcbc4958 Mon Sep 17 00:00:00 2001 From: Ross Wollman Date: Fri, 11 Mar 2022 02:12:07 -0800 Subject: [PATCH] feat(test-runner): more default workers for M1 (#12660) New default is based on the very (unscientific) output of repeated a few times: ``` $ for i in `seq 5 13`; do time npm run ctest -- --reporter=line --workers=$i 'page/*' 'selector*' 'channels*' 'resource-timing*'; done ``` --- packages/playwright-test/src/cli.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/playwright-test/src/cli.ts b/packages/playwright-test/src/cli.ts index 7f790c45b2..540bf81ca6 100644 --- a/packages/playwright-test/src/cli.ts +++ b/packages/playwright-test/src/cli.ts @@ -20,6 +20,7 @@ import { Command } from 'commander'; import fs from 'fs'; import url from 'url'; import path from 'path'; +import os from 'os'; import type { Config } from './types'; import { Runner, builtInReporters, BuiltInReporter, kDefaultConfigFiles } from './runner'; import { stopProfiling, startProfiling } from './profiler'; @@ -27,7 +28,7 @@ import { FilePatternFilter } from './util'; import { showHTMLReport } from './reporters/html'; import { GridServer } from 'playwright-core/lib/grid/gridServer'; import dockerFactory from 'playwright-core/lib/grid/dockerGridFactory'; -import { createGuid } from 'playwright-core/lib/utils/utils'; +import { createGuid, hostPlatform } from 'playwright-core/lib/utils/utils'; import { fileIsModule } from './loader'; const defaultTimeout = 30000; @@ -107,13 +108,16 @@ Examples: async function runTests(args: string[], opts: { [key: string]: any }) { await startProfiling(); + const cpus = os.cpus().length; + const workers = hostPlatform.startsWith('mac') && hostPlatform.endsWith('arm64') ? cpus : Math.ceil(cpus / 2); + const defaultConfig: Config = { preserveOutput: 'always', reporter: [ [defaultReporter] ], reportSlowTests: { max: 5, threshold: 15000 }, timeout: defaultTimeout, updateSnapshots: 'missing', - workers: Math.ceil(require('os').cpus().length / 2), + workers, }; if (opts.browser) {