({ runs = 10 })
| 54 | const numOfProfiles = profiles.length; |
| 55 | |
| 56 | export 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…