More efficient comparison of the same and finite numbers#82
Merged
agdavydov81 merged 1 commit intoepam:masterfrom Jul 27, 2023
Merged
More efficient comparison of the same and finite numbers#82agdavydov81 merged 1 commit intoepam:masterfrom
agdavydov81 merged 1 commit intoepam:masterfrom
Conversation
1. CASE 2 moved to be tested first 2. CASE 1 & 3 tested only for numbers that have steering bits 3. CASE 4 refactored to fast passing for non-zero values 4. CASE 5 refactored to remove redundant comparison
|
Hi! |
Author
|
Please, for yet more efficient comparison of finite numbers replace: by |
Author
|
@agdavydov81 Have you had any chance to review this PR closely? |
|
Greatly sorry for delay. |
|
I'm wondering: why do you invert some ternary operators? Is it just for looks or performance? |
|
@plokhotnyuk Great work! Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It speeds up the comparison operation in 1.2x-1.5x times for
the sameandfinitenumbers, while slows down comparison ofNaNandInfinitynumbers in 1.1x-1.5x timesThe following benchmark was used to test performance:
Bellow are results from Core i7-11700 on different JVMs.
Oracle GraalVM JDK 20
Before
After
OpenJDK 17
Before
After