Skip to content

Commit a573049

Browse files
rubennortefacebook-github-bot
authored andcommitted
Improve support for multi-config benchmarks (#51559)
Summary: Pull Request resolved: #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
1 parent 0ff4566 commit a573049

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

packages/react-native-fantom/runner/entrypoint-template.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,22 @@
99
*/
1010

1111
import type {SnapshotConfig} from '../runtime/snapshotContext';
12-
import type {
13-
FantomTestConfigJsOnlyFeatureFlags,
14-
FantomTestConfigReactInternalFeatureFlags,
15-
} from './getFantomTestConfigs';
12+
import type {FantomTestConfig} from './getFantomTestConfigs';
13+
14+
import formatFantomConfig from './formatFantomConfig';
1615

1716
module.exports = function entrypointTemplate({
1817
testPath,
1918
setupModulePath,
2019
featureFlagsModulePath,
21-
featureFlags,
22-
reactInternalFeatureFlags,
20+
testConfig,
2321
snapshotConfig,
2422
isRunningFromCI,
2523
}: {
2624
testPath: string,
2725
setupModulePath: string,
2826
featureFlagsModulePath: string,
29-
featureFlags: FantomTestConfigJsOnlyFeatureFlags,
30-
reactInternalFeatureFlags: FantomTestConfigReactInternalFeatureFlags,
27+
testConfig: FantomTestConfig,
3128
snapshotConfig: SnapshotConfig,
3229
isRunningFromCI: boolean,
3330
}): string {
@@ -45,20 +42,20 @@ module.exports = function entrypointTemplate({
4542
import {registerTest} from '${setupModulePath}';
4643
import {setConstants} from '@react-native/fantom';
4744
${
48-
Object.keys(featureFlags).length > 0
45+
Object.keys(testConfig.flags.jsOnly).length > 0
4946
? `import * as ReactNativeFeatureFlags from '${featureFlagsModulePath}';
5047
5148
ReactNativeFeatureFlags.override({
52-
${Object.entries(featureFlags)
49+
${Object.entries(testConfig.flags.jsOnly)
5350
.map(([name, value]) => ` ${name}: () => ${JSON.stringify(value)},`)
5451
.join('\n')}
5552
});`
5653
: ''
5754
}
5855
${
59-
Object.keys(reactInternalFeatureFlags).length > 0
56+
Object.keys(testConfig.flags.reactInternal).length > 0
6057
? `import ReactNativeInternalFeatureFlags from 'ReactNativeInternalFeatureFlags';
61-
${Object.entries(reactInternalFeatureFlags)
58+
${Object.entries(testConfig.flags.reactInternal)
6259
.map(
6360
([name, value]) =>
6461
`ReactNativeInternalFeatureFlags.${name} = ${JSON.stringify(value)};`,
@@ -69,6 +66,7 @@ ${
6966
7067
setConstants({
7168
isRunningFromCI: ${String(isRunningFromCI)},
69+
fantomConfigSummary: '${formatFantomConfig(testConfig)}',
7270
});
7371
7472
registerTest(() => require('${testPath}'), ${JSON.stringify(snapshotConfig)});

packages/react-native-fantom/runner/runner.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ module.exports = async function runTest(
207207
testPath: `${path.relative(BUILD_OUTPUT_PATH, testPath)}`,
208208
setupModulePath: `${path.relative(BUILD_OUTPUT_PATH, setupModulePath)}`,
209209
featureFlagsModulePath: `${path.relative(BUILD_OUTPUT_PATH, featureFlagsModulePath)}`,
210-
featureFlags: testConfig.flags.jsOnly,
211-
reactInternalFeatureFlags: testConfig.flags.reactInternal,
210+
testConfig,
212211
snapshotConfig: {
213212
updateSnapshot: snapshotState._updateSnapshot,
214213
data: getInitialSnapshotData(snapshotState),

packages/react-native-fantom/src/Benchmark.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,15 @@ export function suite(
171171
}
172172

173173
function printBenchmarkResults(bench: Bench) {
174+
const {fantomConfigSummary} = getConstants();
174175
const longestTaskNameLength = bench.tasks.reduce(
175176
(maxLength, task) => Math.max(maxLength, task.name.length),
176177
0,
177178
);
178179
const separatorWidth = 137 + longestTaskNameLength - 'Task name'.length;
179-
const benchmarkName = bench.name ?? 'Benchmark';
180+
const benchmarkName =
181+
(bench.name ?? 'Benchmark') +
182+
(fantomConfigSummary ? ` (${fantomConfigSummary})` : '');
180183

181184
console.log('-'.repeat(separatorWidth));
182185
console.log(

packages/react-native-fantom/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,12 @@ export const unstable_benchmark = Benchmark;
522522

523523
type FantomConstants = $ReadOnly<{
524524
isRunningFromCI: boolean,
525+
fantomConfigSummary: string,
525526
}>;
526527

527528
let constants: FantomConstants = {
528529
isRunningFromCI: false,
530+
fantomConfigSummary: '',
529531
};
530532

531533
export function getConstants(): FantomConstants {

packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-benchmark-itest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @fantom_flags enableAccessToHostTreeInFabric:true
7+
* @fantom_flags enableAccessToHostTreeInFabric:true enableIntersectionObserverEventLoopIntegration:*
88
* @flow strict-local
99
* @format
1010
*/

0 commit comments

Comments
 (0)