Skip to content

Instantly share code, notes, and snippets.

@ijuma
Created February 23, 2011 06:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ijuma/840120 to your computer and use it in GitHub Desktop.
Save ijuma/840120 to your computer and use it in GitHub Desktop.
StrictMath vs FastMath vs Math
Intel Core i7 CPU 860 2.80GHz
Running org.apache.commons.math.util.FastMathTestPerformance
Name StrictMath FastMath Math Runs=10000000 Java 1.6.0_25-ea (1.6.0_25-ea-b01) Java HotSpot(TM) 64-Bit Server VM (20.0-b08)
log 71 1.0 39 0.5555 21 0.2953
log10 94 1.0 108 1.1466 20 0.2174
log1p 74 1.0 103 1.3986 76 1.0269
pow 244 1.0 140 0.5726 238 0.9752
powII 159 1.0 120 0.7582 149 0.9415
exp 53 1.0 26 0.4959 39 0.7323
sin 42 1.0 34 0.8286 35 0.8464
asin 345 1.0 135 0.3911 347 1.0055
cos 46 1.0 37 0.8064 34 0.7414
acos 340 1.0 139 0.4079 354 1.0383
tan 80 1.0 68 0.8462 51 0.6461
atan 64 1.0 64 0.9931 66 1.0285
atan2 103 1.0 95 0.9257 104 1.0069
hypot 598 1.0 34 0.0573 592 0.9906
cbrt 95 1.0 67 0.7088 96 1.0151
sqrt 9 1.0 9 0.9818 9 1.0069
cosh 84 1.0 60 0.7248 85 1.0221
sinh 95 1.0 68 0.7159 98 1.0352
tanh 120 1.0 86 0.7193 117 0.9751
expm1 66 1.0 66 0.9961 66 1.0102
abs 1 1.0 5 2.8708 2 1.4429
Running org.apache.commons.math.util.FastMathTestPerformance
Name StrictMath FastMath Math Runs=10000000 Java 1.7.0-ea (1.7.0-ea-b130) Java HotSpot(TM) 64-Bit Server VM (21.0-b02)
log 66 1.0 39 0.5900 20 0.3102
log10 86 1.0 107 1.2369 20 0.2415
log1p 68 1.0 105 1.5388 70 1.0281
pow 214 1.0 139 0.6499 202 0.9434
powII 135 1.0 125 0.9273 125 0.9327
exp 56 1.0 27 0.4892 37 0.6726
sin 40 1.0 34 0.8710 35 0.8797
asin 323 1.0 134 0.4164 327 1.0121
cos 43 1.0 37 0.8695 33 0.7779
acos 320 1.0 142 0.4439 325 1.0140
tan 60 1.0 67 1.1187 47 0.7807
atan 52 1.0 65 1.2566 53 1.0168
atan2 94 1.0 97 1.0329 93 0.9834
hypot 576 1.0 33 0.0589 575 0.9971
cbrt 93 1.0 67 0.7252 94 1.0129
sqrt 9 1.0 9 1.0103 9 0.9810
cosh 85 1.0 62 0.7313 86 1.0116
sinh 96 1.0 67 0.6998 99 1.0296
tanh 105 1.0 82 0.7823 106 1.0037
expm1 66 1.0 69 1.0505 70 1.0537
abs 2 1.0 5 2.5366 2 0.9077
@Artoria2e5
Copy link

@jmsblah left column of each group is some sort of time (presumably nanoseconds per call); right column is time ratio relative to the leftmost group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment