Created
April 19, 2021 04:07
-
-
Save eugenehp/e331f95d6d7752cdfa946aab0235a424 to your computer and use it in GitHub Desktop.
RNBenchmark
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
suite | |
.add('expo-random [Sync]', () => { | |
getRandomBytes(SIZE); | |
}) | |
.add('expo-random [Async]', async () => { | |
await getRandomBytesAsync(SIZE); | |
}) | |
.add('react-native-randomness', () => { | |
randomnessRandomBytes(SIZE); | |
}) | |
.add('get-random-values-polypony', () => { | |
getRandomValues(new Uint8Array(SIZE)); | |
}) | |
.add('react-native-get-random-values', () => { | |
global.crypto.getRandomValues(new Uint8Array(SIZE)); | |
}) | |
.add('react-native-securerandom', () => { | |
generateSecureRandom(SIZE); | |
}) | |
.add('react-native-randombytes [SJCL]', () => { | |
randomBytes(SIZE); | |
}) | |
.add('react-native-randombytes [Native]', async () => { | |
await new Promise((resolve, _reject) => { | |
randomBytes(SIZE, resolve); | |
}); | |
}) | |
.add('react-native-simple-crypto', () => { | |
RNSimpleCrypto.utils.randomBytes(SIZE); | |
}) | |
.on(EventType.COMPLETE, (_event: Event) => { | |
setResults(suite.toString()); | |
console.log(JSON.stringify(suite.toJSON(), null, 2)); | |
}) | |
.run({async: true}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment