Comparison of the Efficiency of string equals and Int = Methods

Source: Internet
Author: User

Recently, I wrote a recursive method. During the comparison and determination, the integer type is integer, And the integer type is created when it is greater than 127 or less than-128, this is because of the integer-type disassembly box mechanism,

 

The efficiency of the equals and = methods has not been considered before. To avoid errors caused by integer box disassembly mechanism, the integer type is used as string. valueof () method, convert all integer types to strings and use the equals Method for comparison.

 

Later I was inadvertently seen by my master and pointed out this error. I immediately changed it to integer. intvalue () converts the integet type to the int type. After testing, the total data volume is 624 records, saving 32 milliseconds. It turns out that the total data volume is 44 milliseconds and the total data volume is 12 milliseconds.

 

Comparison of the Efficiency of string equals and Int = Methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.