Is the performance difference between C ++ and Java so big?

Source: Internet
Author: User

A large number of strings are known, which are stored in methods such as "01", "02", "0101", and "0101002" to generate correct upper-lower-level relationships. For example, the level 01 and 02 are equal, and the Level 01 is 0101002 and the level 0101 is lower. The length of the string is not fixed, and the width of each level is not fixed. Actually, the serial number of a known unit in the project generates a parent-child relationship. Vc6 is used to implement a program, and vector is used with map. The sameCodeAfter being translated into Java, we were surprised by the comparison. It takes several seconds for C ++ to implement the 2000 strings, while Java's 20 million strings are in over 2000 milliseconds, that is, more than 2 seconds! C ++ uses stlport for better performance, but far below the performance of Java!

The suspect is related to the string processing of C ++.

As a souvenir.

Later, I found the cause, and changed the vector to the reference for passing. Because I am used to Java, I just want to directly pass the vector variable. Which of the following statements does C ++ copy a copy!

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.