Dbms_utility. Get_time and Dbms_utility. Get_cpu_time comparison
Original link:http://www.oracle-developer.net/display.php?id=307
developers have always been familiar with dbms_utility. The Get_time function. Common terms test the interval of 2 points in a program, that is, the program is time consuming.
To the 10g,oracle and add a dbms_utility. The Get_cpu_time function. This new function is used to measure the CPU time used at 2 points in time.
Let's illustrate the difference between the following 2 functions by using an example:
Example 1: A computationally intensive (cpu-bound) Type example
This example does not have I/O. This emphasizes CPU-intensive operations, in which case the get_time and Get_cpu_time functions will return almost consistent time-consuming.
DECLARE B1 Pls_integer; B2 Pls_integer; E1 Pls_integer; E2 Pls_integer; n Pls_integer: = 0; BEGIN B1: = dbms_utility. Get_time (); B2: = dbms_utility. Get_cpu_time (); For I in 1.. 100000000 LOOP --null; N: = n + 1; END LOOP; E1: = dbms_utility. Get_time ()-B1; E2: = Dbms_utility. Get_cpu_time ()-B2; Dbms_output. Put_Line (' get_time elapsed = ' | | e1 | | ' Hsecs. '); Dbms_output. Put_Line (' get_cpu_time elapsed = ' | | e2 | | ' Hsecs. '); END;
Get_time elapsed = 175 Hsecs.
Get_cpu_time elapsed = 174 hsecs.
The PL/SQL process has completed successfully.
Example 2:i/o dense (i/o-bound) Type example
This example is more representative of the Plsql program. In this case we will see that the 2 functions will take a different time.
DECLARE B1 Pls_integer; B2 Pls_integer; E1 Pls_integer; E2 Pls_integer; BEGIN B1: = dbms_utility. Get_time (); B2: = dbms_utility. Get_cpu_time (); For R in (SELECT * from All_source) LOOP NULL; END LOOP; E1: = dbms_utility. Get_time ()-B1; E2: = Dbms_utility. Get_cpu_time ()-B2; Dbms_output. Put_Line (' get_time elapsed = ' | | e1 | | ' Hsecs. '); Dbms_output. Put_Line (' get_cpu_time elapsed = ' | | e2 | | ' Hsecs. '); end;/
Get_time elapsed = 324 Hsecs.
Get_cpu_time elapsed = 273 Hsecs.
The PL/SQL process has completed successfully.
-------------------------------------------
Dylan presents.
Oracle dbms_utility. Get_time and Dbms_utility. Get_cpu_time differences