Establish a buffer Zhang Jianzi 01-6-22 at 01-6-22 04:47:33
With its 4GL tools such as Delphi, Visual Basic's early version, PowerBuilder 4.0 is used to be used as a pseudo code, also known as P-Code (Pseudo-Code). P-CODE is interpretation, more accurately, P-CODE uses the virtual machine command to provide shared operation commands for different hosts. When running, the operating system is based on the different platform interpretation of the current P-CODE instruction. A P-CODE command can replace several machine code instructions, which reduces the size of the execution code, and does not overcome the efficiency of the application. First, P-CODE's execution speed is slower than the code, but the size of the file is smaller than the compiled code.
PowerBuilder 5.0 introduces the ability to generate full-end-compiled executable code to increase operational efficiency, but it also guarantees the function of using P-CODE to perform files. The application of P-CODE is enclosed in the dynamic linkage. PBD of the execution document. EXE and PowerBuilder, and the execution document produced by the code is. EXE file and dynamic connection DLL.
What is the compile code
The compile code is first based on P-code, and PowerBuilder first creates a C code according to P-Code, and then translates the C code to the execution document of the machine code. In the process of compiling, all the instructions are the actual machine code. This means that the size of this implementation will be much larger than P-CODE.
The use of compiling code still needs PowerBuilder's log library, and PowerBuilder is still using the shared function library when executing the machine code, and the main point of this is to save memory. Use a moving connection library to avoid writing all the function functions in a can perform the volume of the files. In the Windows environment, there is a copy of the DLL in memory to be used as a number of applications. In addition, PowerBuilder 5.0 compresses the size of a function in a DLL. It is now only 7 dynamic connection libraries when running on a 32-bit platform, and is 4.5m after decompression. It is applicable to the database access, and the RTF editor can be applied, and the RTF editor can be applied to the Database Access PowerBuilder, and the RTF editor.
Compiling code creation
The creation of the code code has the following steps:
In the process of development, PowerScript first is translated into P-Code, when you write a code or function of one event or function in the Script Editor, the system will automatically translate this Script code. When you create a P-code in the engineering brush, PowerBuilder will connect to the unique PBL in the same way, and copy these objects to the specified EXE or PBD file. This is a relatively fast process. Next, P-CODE will be translated into a statement of C language. In this process, the micro-help in the engineering brush window will show the words "Compiling ...", which accounts for 10% of the total compile time. Then to compile the C code and link into machine code, form an executable file and a dynamic connection library. In this step, the micro-help display "generating ...", this compilation process is the most time, will account for about 90% compile time.
Through the top-faced, I see how much the time used by the creation machine code is much more than the use of P-CODE, because the latter is just a two-way code to move. Because of this, we will use the main way to be P-CODE. When the user is used, it will select whether to create a machine code according to the actual situation.
Editing the code of the code:
In the following, the PowerScript code is compiled into a machine code to get a faster run speed:
· Circulation structure
· Floating point operation
· Integer operation
· Function call
However, in additional sides, ediping into machine code does not make the running speed of the running speed, such as involving the map user interface, data library interview, decomposition, string operation, etc. In some cases, the speed of the two codes is the same, such as the call to the resource and the execution of the data window. In this case, you have no way to use the compiled code to improve the speed of the run.
If your application is to perform the code of your own self, for example, if you are in use, the same code is reversible (such as cycling) or a written code master to use to enter the number of hours, this should be used as a compiled code. In the functional call, the machine code is much more faster than P-CODE. Therefore, if you have a large number of call functions in your Script or use a new grammatical form, it will be a good choice. However, you should be remembering, the execution of the code is much larger than the P-Code, because a PowerScript code will be able to compile 5 or 10 c code. When these C code is compiled, the executable code will be much larger than the corresponding P-CODE, so if your application's file size is the primary consideration of your application, or your application is more database access, Then you should choose to use P-CODE. Improve sexual energy
In fact, a good data library material design and application programming module design can greatly increase the performance of applications. If the design is not good, it is made to use the compiled code, nor will it get a good system. This impairment system is set and the rational material bandwidth can make PowerBuilder 5.0 should be used in a very fast.
In PowerBuilder 5.0, the system has increased in some functions, and the use of these powers can be utilized, and the body can be optimized.
• When using the Tab control of PowerBuilder 5.0, select "Create On Demand" in the property of TabPage, when running, only when the user selects this TabPage, PowerBuilder will initially initialize the instance of the TabPage object.
· Use DataStore without using unconviewful DataWindow as data buffers.
· Deliver String, DateTime and other data type parameters can be used to use Read-Only moderation, because of the same reference to the REFERENCE square, PowerBuilder does not need to copy a copy of the copy in memory for these parameters. The same, the REFERENCE is more faster than the Value method.
• The use of local variables is faster than the overall and shared variables, because the local variable is stored in the stack, and the full-time variable is stored in a distinction. This speed difference is more clear than the P-Code when the machine code is used.
· Using an array to assign the data to DataWindow, not the function of the setItem () and GetItem () series, because the former is only used for one function, the all-in-one rows and columns are called.
· To add fast compilation speed, do not write too long in one event or function, divide them into several functions or other reusable code objects.
· Turn your database. In general, Database interviews in applications in customer / server, it is necessary to take a large amount of time, and can use PowerBuilder's characteristics to reduce the time of data library access, including:
1. In 5.0 DBPARM default setting staticbind = 1, that is, PowerBuilder does not first obtain the description of the query data result set structure before retrieving data, so that if the data window is used by the database Errors will occur when the result set does not match. Thus, if you need to change the table query by the data window, and these tables are different, you should set Staticbind's value to 0.
2. DBPARM Default Settings allows the DataWindow to place the blob field, use Data Pipeline to insert the data library into the data of the BLOB field.
3. The settings passing through the DBPARM can support the data library. Setting DBPARM SQLCACACHE = N Will tell PowerBuilder to make a buffer to buffer to build a cursor that does not use the SELECT statement. If you repeat the same SELECT statement multiple times, when there is data in the buffer zone, the speed of the retrieval will be greatly accessed. The default value of SQLCache is 0.
4. Powerbuilder 5.0 has such an option for the data window to keep the fruit set of the data window in the local disk. This can reduce the use of memory, so that you create a larger report, no excessive speed ratio is much slower than putting the results in memory. If your data window will be displayed is not a big statement, it is preferred to put the fruits in memory.
Its injustice
For the user using the PowerBuilder compile code, there is also the following points worth mentioning:
· PowerBuilder's ability to produce the code is very slow, and you should use the main frequency faster computer, up to 64M memory, but in the 5.0 version, multi-CPU is nothing to help.
· The technical master of Watcom is 32-bit techniques, and although there is a 16-bit code option on the 32-bit platform, but the speed is not good. In addition, on the 16-bit platform, we can't produce 32-bit applications.
· Compiling 16-bit application procedure has a limit that code and data cannot exceed 64K, such as the code function or the code in the event, PowerBuilder will generate errors when creating EXE. The solution to our recommendation is to solve the long code to a plurality of small functions, which can also improve the efficiency of running efficiency and benefit you to protect your application code. · If you run a 16-bit application program on Windows NT or Windows 95, you should use the run library that you use should be 16-bit.
· In a PowerBuilder application, we can only use P-CODE's PBD or compile code DLL, and cannot mix it, and unable to create an OLE server using PowerBuilder.
· If you just want to change a DLL, do not want to recompile to all applications, you can choose the menu item of library | build runtime library ... in the Library brush.
• In the compiletation, the system will first remove the comment statement, and there is nothing affected by the interpretation of the interpretation statement in Script.
· When you use PowerBuilder's PLUG-IN technology, you cannot use the compiled code.