ITPub博客

首页 > 数据库 > Oracle > 使用DBMS_UTILITY.GET_TIME来捕获某段代码的执行时间

使用DBMS_UTILITY.GET_TIME来捕获某段代码的执行时间

原创 Oracle 作者:pan_tian 时间:2014-07-02 14:48:25 0 删除 编辑

DBMS_UTILITY.GET_TIME常用于计算某段代码间的时间消耗,DBMS_UTILITY.GET_TIME返回值本身并不是指当前的时间,而是一个the number of 100ths of seconds that have elapsed from an arbitrary time.

Usage Notes

You should not use GET_TIME to establish the current time, but only to calculate the elapsed time between two events. Without GET_TIME, Oracle functions can only record and provide elapsed time in second intervals, which is a very coarse granularity in today\'s world of computing. With GET_TIME, you can get a much finer understanding of the processing times of lines in your program.

Example

DECLARE
 L_START NUMBER;
 L_END NUMBER;
 L_DIFF NUMBER;
BEGIN
 L_START := DBMS_UTILITY.GET_TIME ;
 DBMS_LOCK.SLEEP(10);
 L_END := DBMS_UTILITY.GET_TIME ;
 L_DIFF := (L_END-L_START)/100;
 DBMS_OUTPUT.PUT_LINE(\'Start: \'||to_char(L_START));
 DBMS_OUTPUT.PUT_LINE(\'End:   \'||to_char(L_END));
DBMS_OUTPUT.PUT_LINE(\'Elapsed Time: \'|| l_diff ||\' seconds...\');
END;
                                 
PL/SQL block, executed in 10.51 sec.
Start: 1719251553                   
End:   1719252554                   
Elapsed Time: 10.01 seconds...      
Total execution time 12.09 sec.     
 




<!-- Baidu Button BEGIN -->

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26687597/viewspace-1204554/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: PL/SQL Profiler - DBMS_PROFILER
下一篇: Oracle Form写的九宫格游戏(Sudoku Game)
请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2012-02-18

最新文章