Difference between revisions of "Oracle DBMS UTILITY CPU Time"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
 +
Oracle 10g added this new function to measure the amount of  CPU time by capturing the metric between two points.
 +
 
<pre>
 
<pre>
  
Line 36: Line 38:
  
 
</pre>
 
</pre>
 +
 +
Read more at http://www.oracle-developer.net/display.php?id=307
  
 
[[Category:Database_Scripts]]
 
[[Category:Database_Scripts]]

Latest revision as of 21:44, 14 May 2012

Oracle 10g added this new function to measure the amount of CPU time by capturing the metric between two points.


variable t1 NUMBER
variable cpu1 NUMBER


BEGIN
  :t1 := dbms_utility.get_time;
  :cpu1 := dbms_utility.get_cpu_time;
  dbms_application_info.set_client_info(0);
END;
/

-- Sample CPU Only
Begin
FOR i IN 1..1000000 LOOP
  NULL;
END LOOP;
END;
/

-- Sample CPU and I/O
Begin
FOR i IN (SELECT * FROM all_objects) LOOP
  NULL;
END LOOP;
END;
/

SELECT 
  dbms_utility.get_time - :t1 AS time_hsecs, 
  dbms_utility.get_cpu_time - :cpu1 AS cpu_hsecs,
  userenv('client_info') as calls
FROM dual;


Read more at http://www.oracle-developer.net/display.php?id=307