I am running performance test of calculation of
PI number with
primitives and with
PI with primitives is around 5-6 times faster than the same algorithm, but with
I see a problem with creation of
new BigDecimal object in the
for loop, when adding values - see full code with line marked with comment.
BigDecimal class has
3 methods which allows for addition
1. public BigDecimal add(BigDecimal augend) 2. public BigDecimal add(BigDecimal augend, MathContext mc) 3. public static BigDecimal valueOf(long val)
BigDecimal#valueOf method, the calculation time was even bigger than with
new object creation.
Thus, the question - is it possible to increase performance of the calculation when using