A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2296 below:

[java] Deprecate rule AvoidUsingShortType · Issue #2296 · pmd/pmd · GitHub

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 shorts will hardly ever be noticed (i.e. 0.575 ns).

A program would have to multiply 1 billion shorts to have about a 6 ms impact from using short instead of int. However, loading 1 billion shorts from RAM (i.e. ~2 GB) would cost half as much as loading 1 billion ints 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 ints will minuscule compared to loading the ints.

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