RFR: CODETOOLS-7902829: JMH Statistics implementations do not follow Comparable spec [v2]

Vladimir Sitnikov github.com+213894+vlsi at openjdk.java.net
Thu Feb 18 13:25:46 UTC 2021


On Thu, 18 Feb 2021 12:21:05 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> `Comparable.compareTo` spec says: "Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object."
>> 
>> Unfortunately, that is not followed by JMH Statistics, because they get the order wrong. The tests that are supposed to catch this are also wrong.
>
> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
> 
>  - Merge branch 'master' into CODETOOLS-7902829-statistics-compareTo
>  - CODETOOLS-7902829: JMH Statistics implementations do not follow Comparable spec

jmh-core/src/main/java/org/openjdk/jmh/util/AbstractStatistics.java line 96:

> 94:             double t = getMean();
> 95:             double o = other.getMean();
> 96:             return (t < o) ? -1 : 1;

Should it be `return Double.compareTo(t, o)`?

-------------

PR: https://git.openjdk.java.net/jmh/pull/21


More information about the jmh-dev mailing list