Skip to content

Instantly share code, notes, and snippets.

@eugenehp
Created April 19, 2021 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eugenehp/e331f95d6d7752cdfa946aab0235a424 to your computer and use it in GitHub Desktop.
Save eugenehp/e331f95d6d7752cdfa946aab0235a424 to your computer and use it in GitHub Desktop.
RNBenchmark
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