Affects PMD Version:
6.21.0
Rule:
AvoidUsingShortType
Description:
The premise for AvoidUsingShortType
is "any storage gains found through use of the short
type may be offset by adverse impacts on performance". I realize the keyword is "may". According to this StackOverflow answer, the performance impact is trivial. Here is the impact.
Most code does not spin multiplying numbers together. The impact of occasionally multiplying short
s will hardly ever be noticed (i.e. 0.575 ns).
A program would have to multiply 1 billion short
s to have about a 6 ms impact from using short
instead of int
. However, loading 1 billion short
s from RAM (i.e. ~2 GB) would cost half as much as loading 1 billion int
s from RAM (i.e. ~4 GB). Loading an additional ~2 GB will definitely cost more than 6 ms (probably 33 ms or more). Thus, any performance gains from multiplying int
s will minuscule compared to loading the int
s.
I propose deprecating this rule. Let people use profilers to discover specific places in code where using an int
would be better than using a short
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4