Skip to content

Use ns resolution on non-Windows/OS2#144

Closed
utkarshgupta137 wants to merge 1 commit into
pyutils:mainfrom
utkarshgupta137:main
Closed

Use ns resolution on non-Windows/OS2#144
utkarshgupta137 wants to merge 1 commit into
pyutils:mainfrom
utkarshgupta137:main

Conversation

@utkarshgupta137
Copy link
Copy Markdown

No description provided.

@Theelx
Copy link
Copy Markdown
Collaborator

Theelx commented Sep 14, 2022

I actually attempted this independently when preparing for #165, but when I did some research, it turns out that nanosecond resolution isn't the same as nanosecond accuracy. One nanosecond is only 4 clock cycles on a CPU that runs at 4GHz, and even simple Python lines can easily be hundreds to thousands of clock cycles. If this was a resolution of 100ns, that could be reasonable, but for now 1 microsecond makes the most sense, if only to keep it consistent between platforms.

@utkarshgupta137
Copy link
Copy Markdown
Author

The point of this change is not to get ns resolution but to get 1 extra digit of significance. Plenty of python statements take less then 1 microsecond (around half). So, getting 0.2 or 0.9 instead of 0 or 1 can be useful.
If you try out the change, you'll notice that the scale is still microsecond, but you're seeing a single decimal digit as well.

@utkarshgupta137
Copy link
Copy Markdown
Author

I think this is also the reason why time.perf_counter uses the highest available resolution.

@Erotemic
Copy link
Copy Markdown
Member

I think we should look at incorporating this.

@Theelx
Copy link
Copy Markdown
Collaborator

Theelx commented Nov 4, 2022

I forgot to mention, I incorporated it into #165 around September 20th I believe.

@Erotemic
Copy link
Copy Markdown
Member

Resolved in a different branch.

@Erotemic Erotemic closed this Nov 12, 2022
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