[
https://issues.apache.org/jira/browse/NUMBERS-156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17342939#comment-17342939
]
Matt Juntunen commented on NUMBERS-156:
---------------------------------------
I made my benchmarks more fine-grained. For the accuracy tests, I now have 6
different double input types with different exponent ranges:
||type||min exp||max exp||
|high|+524|+550|
|mid-high|+490|+510|
|mid|-10|+10|
|mid-low|-510|-490|
|low|-550|-524|
|full|-550|+550|
This produced the result below. Note that I renamed the methods as well:
"unsafe" is now "direct", "safe" is now "enorm", and "herbert" is now
"enormMod".
||name||input type||ulp error||std dev||non-finite||
|direct|high|NaN|-0.00|100000|
|enorm|high|0.0472|0.000149|0|
|enormMod|high|0.00132|0.00317|0|
|direct|mid-high|-0.00202|6.39e-06|0|
|enorm|mid-high|0.0140|0.00321|0|
|enormMod|mid-high|-0.00254|8.03e-06|0|
|direct|mid|-0.00178|5.63e-06|0|
|enorm|mid|-0.00178|5.63e-06|0|
|enormMod|mid|-0.00178|5.63e-06|0|
|direct|mid-low|-0.000690|2.18e-06|0|
|enorm|mid-low|0.0141|4.45e-05|0|
|enormMod|mid-low|-0.00146|4.62e-06|0|
|direct|low|3.92e+06|1.12e+06|0|
|enorm|low|0.0467|0.000148|0|
|enormMod|low|0.000620|1.96e-06|0|
|direct|full|-1.10e+04|36.7|9972|
|enorm|full|0.0120|3.81e-05|0|
|enormMod|full|0.000250|7.91e-07|0|
I updated the performance tests similarly.
||Benchmark||(type)||Mode||Cnt||Score||Error||Units||
|direct|low|avgt|5|15028776.543|± 158743.695|ns/op|
|enorm|low|avgt|5|1828956.727|± 18320.060|ns/op|
|enormMod|low|avgt|5|773598.030|± 8925.157|ns/op|
|direct|mid|avgt|5|504703.147|± 18831.161|ns/op|
|enorm|mid|avgt|5|1084495.866|± 250674.590|ns/op|
|enormMod|mid|avgt|5|765963.854|± 55099.014|ns/op|
|direct|high|avgt|5|487172.613|± 8774.864|ns/op|
|enorm|high|avgt|5|1918993.397|± 30906.706|ns/op|
|enormMod|high|avgt|5|799801.640|± 12443.994|ns/op|
|direct|full|avgt|5|906395.152|± 18617.359|ns/op|
|enorm|full|avgt|5|3118820.106|± 53294.919|ns/op|
|enormMod|full|avgt|5|1534622.189|± 30255.237|ns/op|
_Observations_
* In all exponent ranges, {{enormMod}} has an accuracy better than or equal to
{{enorm}}. In many cases, it is far more accurate.
* It is interesting to note that {{enormMod}} has a lower accuracy score on the
mid-high and mid-low ranges, which straddle the scale thresholds.
* {{enormMod}} is significantly more performant than {{enorm}} in all exponent
ranges.
* {{direct}} somehow has the worst performance for numbers in the low range.
I'm not sure how that's possible.
_Conclusion_
As we discussed before, the new safe norm method {{enormMod}} is the clear
winner here. I am going to continue implementing it in a {{Norms}} utility
class, with 2D, 3D, and ND overloads. However, I would like to explore more
about the lower accuracy on the mid-high and low-high ranges.
> SafeNorm 3D overload
> --------------------
>
> Key: NUMBERS-156
> URL: https://issues.apache.org/jira/browse/NUMBERS-156
> Project: Commons Numbers
> Issue Type: Improvement
> Reporter: Matt Juntunen
> Priority: Major
>
> We should create an overload of {{SafeNorm.value}} that accepts 3 arguments
> to potentially improve performance for 3D vectors.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)