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

Increase timing resolution in CacheHashingSpec #1294

Closed
wants to merge 1 commit into from

Conversation

szeiger
Copy link
Contributor

@szeiger szeiger commented Dec 1, 2023

I get times of 0µs vs ~30µs running this test on an M2 Max. The test fails at millisecond precision because usually both values are 0.

I get times of 0µs vs ~30µs running this test on an M2 Max. The test fails at millisecond precision because usually both values are 0.
@Friendseeker
Copy link
Member

Friendseeker commented Dec 1, 2023

I don't quite understand why / 1000000 is not removed from timeUs, but otherwise LGTM.

 def timeUs[R](block: => R): Long = {
    val t0 = System.nanoTime()
    block // call-by-name
    val t1 = System.nanoTime()
    (t1 - t0) / 1000000
  }

Thanks for the PR!

@szeiger
Copy link
Contributor Author

szeiger commented Dec 1, 2023

Huh, you're right, it still measures milliseconds. So it must have been a different problem. I'm not sure why it failed originall, I can't reproduce it anymore.

@szeiger szeiger closed this Dec 1, 2023
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.

2 participants