Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract benchmarking utilities into library #64

Merged
merged 11 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 65 additions & 62 deletions apps/benchmarking-test-app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,89 +8,92 @@
* @format
*/

import { useCallback, useState } from "react";

import { Button, SafeAreaView, StatusBar } from "react-native";
import { Benchmark, simpleBenchmark } from "./src/benchmarks";
import { SafeAreaView, StatusBar } from "react-native";
import { simpleBenchmark } from "./src/benchmarks";
import { bitEcsBenchmark } from "./src/benchmarks/bitEcsBenchmark";
import { threeJsBenchmark } from "./src/benchmarks/threeJsBenchmark";
import { JavaScriptEngineVersion } from "./src/JavaScriptEngineVersion";
import { hyperfluxBenchmark } from "./src/benchmarks/hyperfluxBenchmark";
import { irEcsBenchmark } from "./src/benchmarks/irEcsBenchmark";
import { runHelloTriangle } from "./src/graphicsBenchmarks/HelloTriangle";
import { GraphicsBenchmark } from "./src/graphicsBenchmarks/GraphicsBenchmark";
import { runSignedDistanceField } from "./src/graphicsBenchmarks/SignedDistanceField";
import { runDragonFxaa } from "./src/graphicsBenchmarks/DragonFxaa";
import { runRayTracer } from "./src/graphicsBenchmarks/RayTracer";
import {
runScreenSpaceGlobalIllumination,
runScreenSpaceReflection,
} from "./src/graphicsBenchmarks/ScreenSpaceGlobalIllumination";
import {
BenchmarkDescriptor,
BenchmarkHarness,
} from "react-native-benchmarking-library";

const App = () => {
const [flamegraphEnabled, setFlamegraphEnabled] = useState(false);

const toggleFlamegraph = useCallback(() => {
setFlamegraphEnabled((enabled) => !enabled);
}, []);

const toggleFlamegraphTitle = flamegraphEnabled
? "Disable Flamegraph"
: "Enable Flamegraph";
const BENCHMARK_MATRIX: BenchmarkDescriptor[] = [
{
title: "simpleBenchmark",
benchmarkType: "headless",
benchmarkFn: simpleBenchmark,
},
{
title: "bitEcsBenchmark",
benchmarkType: "headless",
benchmarkFn: bitEcsBenchmark,
},
{
title: "threeJsBenchmark",
benchmarkType: "headless",
benchmarkFn: threeJsBenchmark,
},
{
title: "hyperfluxBenchmark",
benchmarkType: "headless",
benchmarkFn: hyperfluxBenchmark,
},
{
title: "irEcsBenchmark",
benchmarkType: "headless",
benchmarkFn: irEcsBenchmark,
},
{
title: "triangleWebGpuBenchmark",
benchmarkType: "graphics",
benchmarkFn: runHelloTriangle,
},
{
title: "sdfWebGpuBenchmark",
benchmarkType: "graphics",
benchmarkFn: runSignedDistanceField,
},
{
title: "dragonFxaaBenchmark",
benchmarkType: "graphics",
benchmarkFn: runDragonFxaa,
},
{
title: "ssgiBenchmark",
benchmarkType: "graphics",
benchmarkFn: runScreenSpaceGlobalIllumination,
},
{
title: "ssrBenchmark",
benchmarkType: "graphics",
benchmarkFn: runScreenSpaceReflection,
},
{
title: "rayTracerBenchmark",
benchmarkType: "graphics",
benchmarkFn: runRayTracer,
},
];

const App = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView
style={{ flex: 1, backgroundColor: "white" }}
accessibilityLabel="benchmarkSafeArea"
>
<JavaScriptEngineVersion />
<Button
testID="toggleFlamegraph"
title={toggleFlamegraphTitle}
onPress={toggleFlamegraph}
/>
<Benchmark
flamegraphEnabled={flamegraphEnabled}
name="simpleBenchmark"
run={simpleBenchmark}
/>
<Benchmark
flamegraphEnabled={flamegraphEnabled}
name="bitEcsBenchmark"
run={bitEcsBenchmark}
/>
<Benchmark
flamegraphEnabled={flamegraphEnabled}
name="threeJsBenchmark"
run={threeJsBenchmark}
/>
<Benchmark
flamegraphEnabled={flamegraphEnabled}
name="hyperfluxBenchmark"
run={hyperfluxBenchmark}
/>
<Benchmark
flamegraphEnabled={flamegraphEnabled}
name="irEcsBenchmark"
run={irEcsBenchmark}
/>
<GraphicsBenchmark
run={runHelloTriangle}
name="triangleWebGpuBenchmark"
/>
<GraphicsBenchmark
run={runSignedDistanceField}
name="sdfWebGpuBenchmark"
/>
<GraphicsBenchmark run={runDragonFxaa} name="dragonFxaaBenchmark" />
<GraphicsBenchmark
run={runScreenSpaceGlobalIllumination}
name="ssgiBenchmark"
/>
<GraphicsBenchmark run={runScreenSpaceReflection} name="ssrBenchmark" />
<GraphicsBenchmark run={runRayTracer} name="rayTracerBenchmark" />
<BenchmarkHarness items={BENCHMARK_MATRIX} />
</SafeAreaView>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions apps/benchmarking-test-app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-wgpu (0.1.8):
- react-native-wgpu (0.1.18):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1828,7 +1828,7 @@ SPEC CHECKSUMS:
React-microtasksnativemodule: a6501ae1ad0b09070e3c00f5e8150106c0dcde65
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
react-native-release-profiler: d4395df9845d1a30fc77a9e8bd15f08c09fe47f5
react-native-wgpu: 336ca48df0124ddce4290340306b6f5a93bb892c
react-native-wgpu: d43605822e044e7d5b6ec2ff459d47494766b0b9
React-nativeconfig: 271a4a10146950e1ff9825e7f0f84898502a7d84
React-NativeModulesApple: 445c2907955516f0e9abb4b6ce6b7db5531e42ea
React-perflogger: 9c9a8c6b3a0c8956d4201772759a1285450ae301
Expand Down
1 change: 1 addition & 0 deletions apps/benchmarking-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"node-schedule": "^2.1.1",
"react": "18.2.0",
"react-native": "^0.75.0",
"react-native-benchmarking-library": "1.0.0",
"react-native-get-random-values": "^1.11.0",
"react-native-permissions": "^3.10.1",
"react-native-release-profiler": "^0.2.1",
Expand Down
1 change: 0 additions & 1 deletion apps/benchmarking-test-app/src/benchmarks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./Benchmark";
export * from "./simpleBenchmark";
Loading