Skip to content

Commit

Permalink
chore: Fix benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Nov 13, 2024
1 parent 315a01d commit 500900f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions example/src/screens/BenchmarksScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ export function BenchmarksScreen() {
const nitroWidth = React.useRef(new Animated.Value(0)).current
const turboWidth = React.useRef(new Animated.Value(0)).current

const factor = React.useMemo(() => {
if (results == null) return 0
const f = results.turboExecutionTimeMs / results.nitroExecutionTimeMs
return Math.round(f * 10) / 10
}, [results])

const run = async () => {
nitroWidth.setValue(0)
turboWidth.setValue(0)
Expand Down Expand Up @@ -181,16 +187,8 @@ export function BenchmarksScreen() {
<Text style={styles.bold}>
{results.nitroExecutionTimeMs.toFixed(2)}ms
</Text>
{' '}(
<Text style={styles.bold}>
{Math.round(
(results.turboExecutionTimeMs /
results.nitroExecutionTimeMs) *
10
) / 10}
x
</Text>{' '}
faster!)
{' '}(<Text style={styles.bold}>{factor}x</Text>{' '}
{factor > 1 ? 'faster' : 'slower'}!)
</Text>
</View>
</View>
Expand Down

0 comments on commit 500900f

Please sign in to comment.