GET_CPU_TIME function - Retrieve the current CPU time
The GET_CPU_TIME function returns the CPU time in hundredths of a second from some arbitrary point in time.
Syntax
Authorization
EXECUTE privilege on the DBMS_UTILITY module.
Examples
Example 1: The following
SELECT command retrieves the current CPU time.
SELECT DBMS_UTILITY.GET_CPU_TIME FROM DUAL;
get_cpu_time
-------------
603
Example
2: Calculate the elapsed time by obtaining difference between
two CPU time values.
SET SERVEROUTPUT ON@
CREATE OR REPLACE PROCEDURE proc1()
BEGIN
DECLARE cpuTime1 BIGINT;
DECLARE cpuTime2 BIGINT;
DECLARE cpuTimeDelta BIGINT;
DECLARE i INTEGER;
SET cpuTime1 = DBMS_UTILITY.GET_CPU_TIME();
SET i = 0;
loop1: LOOP
IF i > 10000 THEN
LEAVE loop1;
END IF;
SET i = i + 1;
END LOOP;
SET cpuTime2 = DBMS_UTILITY.GET_CPU_TIME();
SET cpuTimeDelta = cpuTime2 - cpuTime1;
CALL DBMS_OUTPUT.PUT_LINE( 'cpuTimeDelta = ' || cpuTimeDelta );
END
@
CALL proc1@