Code review request for 6908131 Pure Java implementations of StrictMath.floor(double) &StrictMath.ceil(double)
Joe Darcy
Joe.Darcy at Sun.COM
Thu Jan 21 22:38:49 UTC 2010
A few comments.
First, part and parcel of doing numerical libraries work is developing
tests; see, "Test where the failures are likely to be"
(http://blogs.sun.com/darcy/entry/test_where_the_failures_are). An
obvious set of tests to run are the regression tests I wrote as part of
the fix for this bug
(http://hg.openjdk.java.net/jdk7/jdk7/jdk/rev/ad1e30930c6c).
Second, micro-benchmarking Java programs is a subtle art; see Cliff
Click's various writeups for guidance, including
http://www.azulsystems.com/events/javaone_2002/microbenchmarks.pdf
http://blogs.azulsystems.com/cliff/2008/03/another-round-o.html
http://www.azulsystems.com/events/javaone_2009/session/2009_J1_Benchmark.pdf
Various benchmarks are examined by the performance team. You can assume
benchmarks Sun publishes numbers on are included in the set of
benchmarks of interest :-)
-Joe
Jeff Hain wrote:
>
> Dmitry,
>
> From your bench, I see FloorCeil methods get in trouble
> with 64 bits architecture, but I never ran anything on 64 bits yet.
>
> I ran your bench on my laptop:
> - DELL inspiron 9400, with (two) Genuine Intel T2300 @ 1.666GHz.
> - java.runtime.version=1.6.0_11-b03
> - java.class.version=50.0
> - os.name=Windows XP
> - os.arch=x86
> - os..version=5.1
>
> I added two patterns:
> - pattern3 ("common" case (for doubles) of non-integer values) {
> 0.1, -0.1,
> 1e4+0.1, -1e4-0.1,
> 1e8+0.1, -1e8-0.1,
> 1e12+0.1, -1e12-0.1,
> (1L<<52)/1.1, -(1L<<52)/1.1}
> - pattern4 (case of integer values) {
> 0.0, -0.0,
> 1e4, -1e4,
> 1e8, -1e8,
> (1L<<52), -(1L<<52),
> (1L<<60), -(1L<<60)}
>
> I also added test of the pure Java StrictMath class (which is the one
> you ran
> as "StrictMath" in your bench?) posted on this subject: "StrictMath_JD".
>
> Here is what I got:
>
> -----------------------------------------
> - CLIENT
> -----------------------------------------
>
> pattern 1:
> empty took 4,42 nsec
> Math.ceil took 63,77 nsec
> Math.floor took 67,55 nsec
> StrictMath.ceil took 64,20 nsec
> StrictMath.floor took 68,76 nsec
> StrictMath_JD.ceil took 52,58 nsec
> StrictMath_JD.floor took 53,57 nsec
> FloorCeil.ceil took 24,31 nsec
> FloorCeil.floor took 18,37 nsec
>
> pattern 2:
> empty took 4,50 nsec
> Math.ceil took 110,95 nsec
> Math.floor took 110,42 nsec
> StrictMath.ceil took 111,38 nsec
> StrictMath.floor took 110,97 nsec
> StrictMath_JD.ceil took 48,95 nsec
> StrictMath_JD.floor took 49,38 nsec
> FloorCeil.ceil took 23,29 nsec
> FloorCeil.floor took 20,81 nsec
>
> pattern 3:
> empty took 4,39 nsec
> Math.ceil took 111,72 nsec
> Math.floor took 114,48 nsec
> StrictMath.ceil took 113,68 nsec
> StrictMath.floor took 114,32 nsec
> StrictMath_JD.ceil took 60,23 nsec
> StrictMath_JD.floor took 60,13 nsec
> FloorCeil.ceil took 27,11 nsec
> FloorCeil.floor took 23,77 nsec
>
> pattern 4:
> empty took 4,38 nsec
> Math.ceil took 113,49 nsec
> Math.floor took 113,34 nsec
> StrictMath.ceil took 110,35 nsec
> StrictMath.floor took 112,95 nsec
> StrictMath_JD.ceil took 43,69 nsec
> StrictMath_JD.floor took 44,28 nsec
> FloorCeil.ceil took 22,09 nsec
> FloorCeil.floor took 18,71 nsec
>
> -----------------------------------------
> - SERVER
> -----------------------------------------
>
> pattern 1:
> empty took 2,40 nsec
> Math.ceil took 64,61 nsec
> Math.floor took 65,14 nsec
> StrictMath.ceil took 63,93 nsec
> StrictMath.floor took 65,99 nsec
> StrictMath_JD.ceil took 37,52 nsec
> StrictMath_JD.floor took 39,77 nsec
> FloorCeil.ceil took 21,36 nsec
> FloorCeil.floor took 13,96 nsec
>
> pattern 2:
> empty took 2,23 nsec
> Math.ceil took 112,42 nsec
> Math.floor took 110,88 nsec
> StrictMath.ceil took 112,05 nsec
> StrictMath.floor took 113,54 nsec
> StrictMath_JD.ceil took 33,98 nsec
> StrictMath_JD.floor took 33,97 nsec
> FloorCeil.ceil took 22,09 nsec
> FloorCeil.floor took 16,75 nsec
>
> pattern 3:
> empty took 2,19 nsec
> Math.ceil took 113,67 nsec
> Math.floor took 113,53 nsec
> StrictMath.ceil took 114,46 nsec
> StrictMath.floor took 115,02 nsec
> StrictMath_JD.ceil took 44,19 nsec
> StrictMath_JD.floor took 43,57 nsec
> FloorCeil.ceil took 25,57 nsec
> FloorCeil.floor took 20,95 nsec
>
> pattern 4:
> empty took 2,45 nsec
> Math.ceil took 108,56 nsec
> Math.floor took 112,96 nsec
> StrictMath.ceil took 109,43 nsec
> StrictMath.floor took 113,14 nsec
> StrictMath_JD.ceil took 30,18 nsec
> StrictMath_JD.floor took 31,07 nsec
> FloorCeil.ceil took 18,11 nsec
> FloorCeil.floor took 15,91 nsec
>
> -----------------------------------------
>
> Jeff
> PS : The ceil and floor I posted here are an extract of a FastMath class
> (I already
> see some people in this mailing list invoking the gods against me
> while having
> a heart attack at the hearing of this class name) I did, and put on
> source
> forge (I already told about it in this list few months ago): maybe
> some of
> you might want to take a look at it (it's called "FastMath", but
> not ALL of
> its treatments are wrong...).
>
>
More information about the core-libs-dev
mailing list