Increasing Java's BigInteger performance

后端 未结 4 412
清歌不尽
清歌不尽 2021-02-04 09:46

How to increase performance of Java\'s Big Integer?

For example, this factorial program:

import java.math.*;
class Fac {
  public static void main(String         


        
4条回答
  •  不思量自难忘°
    2021-02-04 10:36

    Other answers are related to tune the performance using code.

    If you are using java version less than 1.8.0_151, you can tune big integer performance by using the following command options:

    -XX:+UseMontgomerySquareIntrinsic
    -XX:+UseMontgomeryMultiplyIntrinsic
    -XX:+UseSquareToLenIntrinsic
    -XX:+UseMultiplyToLenIntrinsic
    

    After 1.8.0_151, these options are turned on by default.

提交回复
热议问题