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

DBMS_UTILITY.GET_TIME常用于计算某段代码间的时间消耗,DBMS_UTILITY.GET_TIME返回值本身并不是指当前的时间,而是一个the number of100ths 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


[sql]  view plain  copy
 print ?
  1. DECLARE  
  2.  L_START NUMBER;  
  3.  L_END NUMBER;  
  4.  L_DIFF NUMBER;  
  5. BEGIN  
  6.  L_START := DBMS_UTILITY.GET_TIME ;  
  7.  DBMS_LOCK.SLEEP(10);  
  8.  L_END := DBMS_UTILITY.GET_TIME ;  
  9.  L_DIFF := (L_END-L_START)/100;  
  10.  DBMS_OUTPUT.PUT_LINE('Start: '||to_char(L_START));  
  11.  DBMS_OUTPUT.PUT_LINE('End:   '||to_char(L_END));  
  12. DBMS_OUTPUT.PUT_LINE('Elapsed Time: '|| l_diff ||' seconds...');  
  13. END;  
  14.                                    
  15. PL/SQL block, executed in 10.51 sec.  
  16. Start: 1719251553                     
  17. End:   1719252554                     
  18. Elapsed Time: 10.01 seconds...        
  19. Total execution time 12.09 sec.       
  20.    

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

转载于:http://blog.itpub.net/22816976/viewspace-2126046/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值