Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add performance.now() to Worklets #2679

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

mrousavy
Copy link
Contributor

@mrousavy mrousavy commented Dec 2, 2021

Description

Adds support for measuring performance/elapsed time in millisecond precision using Chrono with performance.now() in Worklets.

Changes

  • Inject _chronoNow func in global runtime object

Test code and steps to reproduce

runOnUI(() => {
  'worklet'
  const start = performance.now()
  for (let i = 0; i < 1000000; i++) {}
  const end = performance.now()
  console.log(`Loop took ${end - start} ms!`)
})()

Checklist

  • Included code example that can be used to test this change
  • Updated TS types
  • Added TS types tests
  • Added unit / integration tests
  • Updated documentation
  • Ensured that CI passes

Related Issues

Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be useful for performance profiling 🚀

@piaskowyk piaskowyk merged commit aef72c0 into software-mansion:master Dec 6, 2021
@mrousavy
Copy link
Contributor Author

mrousavy commented Dec 6, 2021

Btw, this is now also aligned with how the original performance.now() works :) (Because of: facebook/react-native@1721efb)

@enesozturk
Copy link
Contributor

enesozturk commented Dec 17, 2021

Before opening a issue wanted to write here, I have the same issue with v2.3.1 in Expo app. Trying to use it with Storybook RN. I have a basic stack:

<Stack.Navigator>
  <Stack.Screen name="Home" component={TabNavigator} />
  <Stack.Screen name="Storybook" component={Story} />
</Stack.Navigator>

When I navigate to Storybook page, it is ok but when press go back. I got the issue.

Screen Shot 2021-12-17 at 21 18 50

Packages:

{
  "expo": "^44.0.0",
  "react-native-reanimated": "~2.3.1",
}

Should I share any other details?

Edit:

@shamilovtim
Copy link
Contributor

^ You probably have to mock it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants