Java – does integer auto boxing and auto boxing provide performance problems?

We are using X for some iterations and other operations; Where x is an integer, not int

Operations may be repeated in some user operations on our system, but mathematical applications are not too complex or numerous, and each user transaction can be up to 10000 times

Will this unpacking and future boxing affect our performance in a few minutes?

Solution

http://download.oracle.com/javase/1.5.0/docs/guide/language/autoboxing.html

"The resulting list may have poor performance because it is a box or unpacking box at each get or set operation, which is fast enough for occasional use, but it would be foolish to use it in a performance critical internal loop

So when should we use automatic packing and unpacking? You need to use reference types and primitives only if there is an impedance mismatch between them, for example, you must put values into a collection It is not appropriate to use automatic packing and unpacking for numerical codes sensitive to scientific calculation or other performance Integer is not a substitute for int; Automatic boxing and unpacking blur the distinction between primitive and reference types, but they do not eliminate it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>