mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Improve support for multi-config benchmarks (#51559)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51559 Changelog: [internal] Improves the support for multi-config benchmarks in Fantom by printing the Fantom configuration summary in the header of the table with the benchmark results for each variant. Reviewed By: rshest Differential Revision: D75281972 fbshipit-source-id: 80caf2e668a30ea1454cb932e91dac91192323bf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0ff4566ac7
commit
a573049c0a
+10
-12
@@ -9,25 +9,22 @@
|
||||
*/
|
||||
|
||||
import type {SnapshotConfig} from '../runtime/snapshotContext';
|
||||
import type {
|
||||
FantomTestConfigJsOnlyFeatureFlags,
|
||||
FantomTestConfigReactInternalFeatureFlags,
|
||||
} from './getFantomTestConfigs';
|
||||
import type {FantomTestConfig} from './getFantomTestConfigs';
|
||||
|
||||
import formatFantomConfig from './formatFantomConfig';
|
||||
|
||||
module.exports = function entrypointTemplate({
|
||||
testPath,
|
||||
setupModulePath,
|
||||
featureFlagsModulePath,
|
||||
featureFlags,
|
||||
reactInternalFeatureFlags,
|
||||
testConfig,
|
||||
snapshotConfig,
|
||||
isRunningFromCI,
|
||||
}: {
|
||||
testPath: string,
|
||||
setupModulePath: string,
|
||||
featureFlagsModulePath: string,
|
||||
featureFlags: FantomTestConfigJsOnlyFeatureFlags,
|
||||
reactInternalFeatureFlags: FantomTestConfigReactInternalFeatureFlags,
|
||||
testConfig: FantomTestConfig,
|
||||
snapshotConfig: SnapshotConfig,
|
||||
isRunningFromCI: boolean,
|
||||
}): string {
|
||||
@@ -45,20 +42,20 @@ module.exports = function entrypointTemplate({
|
||||
import {registerTest} from '${setupModulePath}';
|
||||
import {setConstants} from '@react-native/fantom';
|
||||
${
|
||||
Object.keys(featureFlags).length > 0
|
||||
Object.keys(testConfig.flags.jsOnly).length > 0
|
||||
? `import * as ReactNativeFeatureFlags from '${featureFlagsModulePath}';
|
||||
|
||||
ReactNativeFeatureFlags.override({
|
||||
${Object.entries(featureFlags)
|
||||
${Object.entries(testConfig.flags.jsOnly)
|
||||
.map(([name, value]) => ` ${name}: () => ${JSON.stringify(value)},`)
|
||||
.join('\n')}
|
||||
});`
|
||||
: ''
|
||||
}
|
||||
${
|
||||
Object.keys(reactInternalFeatureFlags).length > 0
|
||||
Object.keys(testConfig.flags.reactInternal).length > 0
|
||||
? `import ReactNativeInternalFeatureFlags from 'ReactNativeInternalFeatureFlags';
|
||||
${Object.entries(reactInternalFeatureFlags)
|
||||
${Object.entries(testConfig.flags.reactInternal)
|
||||
.map(
|
||||
([name, value]) =>
|
||||
`ReactNativeInternalFeatureFlags.${name} = ${JSON.stringify(value)};`,
|
||||
@@ -69,6 +66,7 @@ ${
|
||||
|
||||
setConstants({
|
||||
isRunningFromCI: ${String(isRunningFromCI)},
|
||||
fantomConfigSummary: '${formatFantomConfig(testConfig)}',
|
||||
});
|
||||
|
||||
registerTest(() => require('${testPath}'), ${JSON.stringify(snapshotConfig)});
|
||||
|
||||
+1
-2
@@ -207,8 +207,7 @@ module.exports = async function runTest(
|
||||
testPath: `${path.relative(BUILD_OUTPUT_PATH, testPath)}`,
|
||||
setupModulePath: `${path.relative(BUILD_OUTPUT_PATH, setupModulePath)}`,
|
||||
featureFlagsModulePath: `${path.relative(BUILD_OUTPUT_PATH, featureFlagsModulePath)}`,
|
||||
featureFlags: testConfig.flags.jsOnly,
|
||||
reactInternalFeatureFlags: testConfig.flags.reactInternal,
|
||||
testConfig,
|
||||
snapshotConfig: {
|
||||
updateSnapshot: snapshotState._updateSnapshot,
|
||||
data: getInitialSnapshotData(snapshotState),
|
||||
|
||||
+4
-1
@@ -171,12 +171,15 @@ export function suite(
|
||||
}
|
||||
|
||||
function printBenchmarkResults(bench: Bench) {
|
||||
const {fantomConfigSummary} = getConstants();
|
||||
const longestTaskNameLength = bench.tasks.reduce(
|
||||
(maxLength, task) => Math.max(maxLength, task.name.length),
|
||||
0,
|
||||
);
|
||||
const separatorWidth = 137 + longestTaskNameLength - 'Task name'.length;
|
||||
const benchmarkName = bench.name ?? 'Benchmark';
|
||||
const benchmarkName =
|
||||
(bench.name ?? 'Benchmark') +
|
||||
(fantomConfigSummary ? ` (${fantomConfigSummary})` : '');
|
||||
|
||||
console.log('-'.repeat(separatorWidth));
|
||||
console.log(
|
||||
|
||||
+2
@@ -522,10 +522,12 @@ export const unstable_benchmark = Benchmark;
|
||||
|
||||
type FantomConstants = $ReadOnly<{
|
||||
isRunningFromCI: boolean,
|
||||
fantomConfigSummary: string,
|
||||
}>;
|
||||
|
||||
let constants: FantomConstants = {
|
||||
isRunningFromCI: false,
|
||||
fantomConfigSummary: '',
|
||||
};
|
||||
|
||||
export function getConstants(): FantomConstants {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @fantom_flags enableAccessToHostTreeInFabric:true
|
||||
* @fantom_flags enableAccessToHostTreeInFabric:true enableIntersectionObserverEventLoopIntegration:*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user