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

Record computation time #622

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thaihuyhung
Copy link

Hi,

Currently, I'm using recomputations count to verify the performance of our selectors in local environment. This gave us a lot of insights into how we implemented the selectors. Besides the re-computation count, I'd like to know more about how long is the execution/computation time as well. Therefore I create this PR for this change. Hope it would be helpful for everyone.

Sorry if I didn’t follow any guidelines, this is the first time I submit PR.

Thank you.

Record computation time along with re-computation count
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d4f6f86:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration

@aryaemami59
Copy link
Contributor

Looks very interesting, can we disable during production mode?

@@ -46,6 +46,14 @@ export function setInputStabilityCheckEnabled(enabled: StabilityCheck) {
globalStabilityCheck = enabled
}

function getTime() {

Choose a reason for hiding this comment

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

I am wondering if wouldn't be better if definition of getTime would look like:

const getTime = performance && typeof performance.now === 'function'
  ? performance.now.bind(performance)
  : Date.now.bind(Date)

In that case no extra conditions or jumps will be done while the function executes.

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.

3 participants