易语言(Easy language)
1. u integers and long integers
章乐The easiest way to improve code speed is to u the correct data type. Maybe you don't believe it,
红豆薏仁Correct lection of data types can greatly improve the performance of code. In most cas, the programmer can replace the short integer, decimal and decimal double precision variable is an integer (Integer) or long integer (Long) type variables, becau the ability of easy language processing or long integers is much higher than that of veral other types of data processing.
In most cas, the reason programmers choo to u decimal or double precision decimal is becau they can save decimal numbers. But decimals can also be stored in variables of integer type. For example, when there are three decimal points in a program, you can get the result by dividing the value stored in the integer variable by 1000. According to my experience, the u of integers and long integers instead of short integer, decimal and double precision decimal type, the code can run nearly 10 times faster.
But we don't always emphasize using integer and long integer, becau the definition of data types are also involved in the program is a key issue, data curity, and no standard definition of frequent data type will cau the algorithm loopholes, is the problem of data curity and critical calculation of financial and engineering. The decimal point, accuracy is very nsitive data, ud to regulate only double
precision data. In addition, for integer will lead to the readability of the program declined sharply.
2. avoid using generic data
A generic variable requires 16 bytes of space to store data, and an integer (Integer) requires only 2 bytes. Usually, the purpo of using universal variables is to reduce the amount of work and the amount of code to design, and some programmers u it in a simple way. However, if a software has been rigorously designed and coded according to specifications, the variant type can be avoided completely.
3. avoid using attributes as much as possible
In the usual code, the most common, inefficient code is the repeated u of attributes (Property), esp
ecially in loops, when variables can be ud. You know, the speed of the access variable is about 20 times the speed of the access attribute. The following code is ud by many programmers in the program:
Container name: numeric type: integer type
Container name: container type: integer type
Counter cycle head (7, container)
酒店设计方案Text 1. text content = 1. + content + text (# newline (numerical * container))
Counting cycle tail ()
The following code is 20 times faster than the previous code.
Container name: numeric type: integer type
Container name: container type: integer type一颗小桃树
Container name: Text Type: text type
陕西社保
Text = text 1. content
Counter cycle head (7, container)
关于圆的手抄报Text = + text + text (# newline (numerical * container))
Counting cycle tail ()
Text 1. content = text
In addition, this involves a programming idea, using attributes as variables, most cas can simplify the algorithm. So sometimes you can't just emphasize replacing attributes with variables.
6. avoid calling very short subroutines
邀请函素材
Calling subroutines with only a few lines of code is also uneconomical - the time spent in calling subroutines may take longer than the code in the subroutine. In this ca, you can copy the code in the subroutine to the place where the subroutine was called.
But sometimes a small subroutine can be called many times, not only two or three times, and then it should be called.
7. reduce the reference to the child object
In easy language, the object is referenced by using. For example:
Window 1. edit box 1.
In the example above, the program refers to two objects: window 1 and edit box 1. The efficiency of using this method is very low. But unfortunately,
There is no way to avoid it. My "multimedia module" has this shortcoming.
8. check whether the text data is empty
Most easy language urs u the following method when checking whether text data is empty:
If (text 1. content = "")
Notes: execution operations
End if
Unfortunately, the amount of processing required for string comparisons is even greater than the read attributes. So I
suggest you u the following methods:
If (to numerical value (text 1. content) = 0)
Notes: execution operations
End if
Another difference is that the problem is that when the text string is a non numeric type such as "ABC", the numeric value ("ABC") =0 is not empty. Text comparison efficiency is not low, in the bottom of the algorithm, usually will directly compare the length will continue to compare content.
9. u arrays, not multiple variables
When you have multiple variables that store similar data, you can think of replacing them with an array. Arrays are one of the most efficient data structures in an easy language.
10. try to u dynamic arrays instead of static arrays
和文艺
Using dynamic arrays does not have much impact on the execution speed of code, but in some cas it can save a lot of resources.
11. destroy objects
No matter what software is written, programmers need to consider releasing the memory space occupied by the software when the ur decides to terminate the software running. Unfortunately, many urs don't em to care much about it. The