How to measure time- the simplest solution!

A year ago, I wrote how to measure the duration of the process  using variables of the TIMESTAMP and DATE type.
And today I'll show you the easiest way of all. And what's interesting - using NUMBER data type.

In the DBMS_UTILITY package we have the GET_TIME function, which is used to measure time. The function should be called twice - at the beginning and at the end of the process. We get the time in hundredths of a second by subtracting the first value from the second.

Code:
 set serveroutput on  
 declare  
   nTimeStart number := dbms_utility.get_time;  
   nTimeEnd number;  
 begin  
   dbms_session.sleep(10);  
   nTimeEnd := dbms_utility.get_time;  
   dbms_output.put_line ((nTimeEnd - nTimeStart)/100 || ' sec');  
 end;  
10 sec
Simple and legible - what more could you want:D

Komentarze