Last active
May 22, 2024 00:56
-
-
Save zetavg/6f1d27ca5c9a401a69a0b2d637ecdd00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react'; | |
import registerRootComponent from 'expo/build/launch/registerRootComponent'; | |
/* PASTE THE CODE HERE */ | |
function App() { | |
useEffect(() => { | |
const timer = setTimeout(() => { | |
const iterations = 1e6; | |
const start = performance.now(); | |
for (let i = 0; i < iterations; i++) { | |
fn(); | |
} | |
const end = performance.now(); | |
console.log(`${end - start}ms`); | |
}, 1000); | |
return () => { | |
clearTimeout(timer); | |
}; | |
}, [fn]); | |
return null; | |
} | |
registerRootComponent(App); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react'; | |
import { runOnUI } from 'react-native-reanimated'; | |
import registerRootComponent from 'expo/build/launch/registerRootComponent'; | |
/* PASTE THE CODE HERE, WITH 'worklet' inserted in fn. */ | |
function test() { | |
'worklet'; | |
const iterations = 1e6; | |
const start = performance.now(); | |
for (let i = 0; i < iterations; i++) { | |
fn(); | |
} | |
const end = performance.now(); | |
console.log(`${end - start}ms`); | |
} | |
function App() { | |
useEffect(() => { | |
const timer = setTimeout(() => { | |
runOnUI(test)(); | |
}, 1000); | |
return () => { | |
clearTimeout(timer); | |
}; | |
}, [fn]); | |
return null; | |
} | |
registerRootComponent(App); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obj = { | |
a: 1, | |
b: 2, | |
c: 3, | |
d: 4, | |
}; | |
function fn() { | |
return obj.a; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obj = { | |
a: 1, | |
b: 2, | |
c: 3, | |
d: 4, | |
}; | |
const { a } = obj; | |
function fn() { | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment