The impact of data types on software performance

Source: Internet
Author: User
Tags array interface resource
Data | data type | Performance Badregexpmatcher requires Mailbot to convert input text from a character array to a string object, resulting in unnecessary object creation. However, the funny thing is that in order to make it easier to use input text, Badregexpmatcher immediately converts a string object to an array of characters, which not only generates another object, but also means that you dickens the results of the call to the original data provided by the calling program. Mailbot and Badregexpmatcher do not require a string object, and a string object seems to exist only for exchanging text data between components.

in the Badregexpmatcher example above, string is just a type for interchange, neither the calling program nor the invoked program needs to use data types for interchange to represent data, but they can easily convert it to other data types. Although the use of data types for Exchange when defining an interface can reduce complexity while maintaining flexibility, it sometimes leads to performance losses.

One of the most common examples of data types used for
is the JDBC ResultSet interface, where no interface to a database represents the results returned with JDBC resultset, but the JDBC driver can easily convert the results returned by the database to JDBC ResultSet type data. Similarly, there is no client software that uses DBC resultset data to represent data records, but you can convert resultset data to the desired data type without any difficulty. We can accept this "superfluous" in JDBC because it has the advantages of being standard and portability across databases. In any case, the loss of performance caused by data types for Exchange is a noteworthy issue.

in Regexpmatcher, using a String object to define an interface is less helpful for reducing complexity or increasing portability, and has a considerable impact on performance, which is not worth the candle. It is often tempting to use interchangeable types when designing interfaces, because it makes the interface look "clean", but you should be sure that your compromise is sensible. Sometimes ━━ like Regexpmatcher, callers can use a variety of input and output formats, and should consider how they can be more easily satisfied with their needs.

It is worth noting that quantifying the impact of the use of interchangeable types on performance is not an easy thing to do. If the code that invokes Badregexpmatcher is parsed, it assigns the Run-time library to create a string object for input, which is generated to meet the requirements of the badregexpmatcher. If you want to measure the real impact of a component on performance, you need to evaluate not only the resource utilization of the code, but also the resource utilization of the calling code and the code that calls back, and it is very difficult to use the standard profiling Tools to do the profiling work.

Related Article

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: 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.