Oracle dbms_utility. Get_time and Dbms_utility. Get_cpu_time differences

Source: Internet
Author: User

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

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: info-contact@alibabacloud.com 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.