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

More efficient ranges for Word32 #65

Merged
merged 5 commits into from
Apr 6, 2020

Conversation

idontgetoutmuch
Copy link
Owner

@idontgetoutmuch idontgetoutmuch commented Apr 2, 2020

This can now be merged (subject to review of course). I don't think a drop in coverage of 0.1% is serious. Of course we should write more tests but in separate PRs.

@idontgetoutmuch idontgetoutmuch self-assigned this Apr 2, 2020
@lehins lehins changed the base branch from instances-and-warnings to interface-to-performance April 4, 2020 20:10
@idontgetoutmuch
Copy link
Owner Author

@lehins @curiousleo are you happy for me to merge this?

Here are the results for ranges using just bitmask

  Next timing range-restricted System.Random.randomR:
        811,624 randoms generated [System.Random Ints]        ~ 3,312 cycles/int
     10,959,894 randoms generated [System.Random Word16s]     ~ 245 cycles/int
     26,684,542 randoms generated [System.Random Floats]      ~ 101 cycles/int
     28,584,570 randoms generated [System.Random CFloats]     ~ 94.05 cycles/int
     28,721,171 randoms generated [System.Random Doubles]     ~ 93.61 cycles/int
     24,878,218 randoms generated [System.Random CDoubles]    ~ 108 cycles/int
      1,168,144 randoms generated [System.Random Integers]    ~ 2,302 cycles/int
        441,528 randoms generated [System.Random Bools]       ~ 6,089 cycles/int
        380,428 randoms generated [System.Random Chars]       ~ 7,067 cycles/int
         11,658 randoms generated [System.Random BIG Integers] ~ 230,614 cycles/int

and here are the results when using integer multiply for Word32

 Next timing range-restricted System.Random.randomR:
        865,075 randoms generated [System.Random Ints]        ~ 3,087 cycles/int
     16,030,334 randoms generated [System.Random Word16s]     ~ 167 cycles/int
     38,619,176 randoms generated [System.Random Floats]      ~ 69.15 cycles/int
     34,920,119 randoms generated [System.Random CFloats]     ~ 76.47 cycles/int
     37,484,083 randoms generated [System.Random Doubles]     ~ 71.24 cycles/int
     37,316,003 randoms generated [System.Random CDoubles]    ~ 71.56 cycles/int
      1,388,163 randoms generated [System.Random Integers]    ~ 1,924 cycles/int
        761,498 randoms generated [System.Random Bools]       ~ 3,507 cycles/int
        787,128 randoms generated [System.Random Chars]       ~ 3,393 cycles/int
         12,093 randoms generated [System.Random BIG Integers] ~ 220,823 cycles/int

I’d say it was definitely worth merging

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. Performance boost is always nice ;)

@idontgetoutmuch idontgetoutmuch force-pushed the faster-range-for-Word32 branch from 01503a7 to 126d534 Compare April 6, 2020 08:48
Copy link
Collaborator

@curiousleo curiousleo left a comment

Choose a reason for hiding this comment

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

🎉

@idontgetoutmuch idontgetoutmuch merged commit b820dba into interface-to-performance Apr 6, 2020
@idontgetoutmuch idontgetoutmuch deleted the faster-range-for-Word32 branch April 6, 2020 09:21
curiousleo pushed a commit that referenced this pull request May 19, 2020
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