使用DBMS_UTILITY.GET_TIME来捕获某段代码的执行时间
2012-12-03 16:49
579 查看
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
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.
相关文章推荐
- 【转】用dbms_utility.get_time来估算过程的执行时间
- 统计代码执行时间,使用Stopwatch和UserProcessorTime的区别
- 使用 console.time() 计算js代码执行时间
- dbms_utility获取CPU时间(get_cpu_time)
- Linux使用time命令获取命令执行时间
- Linux时间函数之 gettimeofday() 函数之使用方法
- Linux时间函数之gettimeofday()函数之使用方法
- 牛刀小试:使用Reactive Extensions(Rx),一行代码实现多线程任务执行规定时间后自动停止
- DBMS_UTILITY.get_time——比较时间差
- 测试代码的执行时间:%time和%timeit
- Linux时间函数之gettimeofday()函数之使用方法
- DBMS_UTILITY.GET_CPU_TIME和DBMS_UTILITY.GET_TIME
- 使用php-timeit估计php函数的执行时间
- cygwin中使用time查看程序执行时间
- linux下命令执行时间统计工具time使用小结
- node测试一段代码执行的时间长度(console.time,console.timeEnd)
- Linux时间函数之gettimeofday()函数之使用方法
- 牛刀小试:使用Reactive Extensions(Rx),一行代码实现多线程任务执行规定时间后自动停止
- Linux系统使用time计算命令执行的时间
- 使用Intel编译器(5)PGO(3)评测函数或循环执行时间(Profile Function or Loop Execution Time)