MCPcopy Create free account
hub / github.com/meliorence/react-native-render-html / useBenchmark

Function useBenchmark

apps/benchmarking/useBenchmark.js:56–83  ·  view source on GitHub ↗
({ runs = 10 })

Source from the content-addressed store, hash-verified

54const numOfProfiles = profiles.length;
55
56export default function useBenchmark({ runs = 10 }) {
57 const [state, dispatch] = useReducer(reducer, {
58 state: 'WAIT_BENCH',
59 benchmarks: null
60 });
61 const onLayout = useCallback(() => {
62 requestAnimationFrame(() => dispatch({ type: 'REGISTER_RUN' }));
63 }, []);
64 const launch = useCallback(() => {
65 dispatch({ type: 'LAUNCH_BENCH', runs, numOfProfiles });
66 }, [runs]);
67 useEffect(
68 () =>
69 exec(state, {
70 WAIT_RUN: () => {
71 requestAnimationFrame(() => dispatch({ type: 'NEXT_RUN' }));
72 }
73 }),
74 [state, runs]
75 );
76 return {
77 ...state,
78 launch,
79 onLayout,
80 profile:
81 typeof state.profileId === 'number' ? profiles[state.profileId] : null
82 };
83}

Callers 1

Benchmark.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…