Design of software performance (3) Influence of data type on software performance

zhaozj2021-02-11  195

Design of software performance (3) Influence of data type on software performance Liu Yanqing Yesky

BadRegexpmatcher requires Mailbot to convert the text by the character array into a String object, resulting in unnecessary object creation. However, funny is to make it easier to use input text, BadRegexpmatcher will immediately convert the String object to a character array, which will not only generate another object, but also it means that you have taken the results of the Jiu Niu two tiger. The data that is originally provided with the call does not require both, Mailbot and BadRegexpmatcher do not require the use of String objects, and the String object seems to be only existing to exchange text data between components.

In the above BadRegexpmatcher example, String is just a type for exchange, whether the calling program is still required to use the data type for exchange, but they can easily put it with others. The data type is converted. Although the data type for exchange for exchange can be reduced under the premise of maintaining flexibility, it can sometimes lead to performance.

One of the most common examples of the type of data for exchange is the JDBC ResultSet interface. There is no database for the interface to represent the result returned by JDBC ResultSet, but the JDBC driver can easily convert the results returned by the database into JDBC ResultSet data. . Similarly, there is no client software to represent data records with DBC ResultSet type data, but you can convert RESULTSET data to the required data type without any strength. In JDBC we can accept this "more such", because it has the benefits of stability and transplantability across the database. In any case, performance losses caused by the type of exchange of exchanges are a worthless issue.

In regexpmatcher, use String objects when defining interfaces is not much more helpful to reduce complexity or increase portability, but there is a considerable impact on performance, which is not worthless. It is often very attractive to use interchangeable type when designing interfaces, because this can make the interface look more "clean", but you should be aware of your compromise for this. Sometimes, just like regexpmatcher, the calling program can use multiple inputs, output formats, should consider how to meet their needs more easily.

It is worth noting that it is not an easy thing to quantify the performance of performance using the interchangeable type. If you analyze the code called BadRegexpmatcher, it will assign the running time library to create the input String object, which is generated to meet the requirements of BadRegexpmatcher. If you want to measure the true impact of a component, you need not only the resource utilization of the code, but also assess the establishment of the code that is called, and the resource utilization of the call returned. It is very difficult to use the standard analysis tool. of.

转载请注明原文地址:https://www.9cbs.com/read-4524.html

New Post(0)