-- 创建 runstats 包。其中包括 3 个简单 API 调用:
create or replace package runstats_pkg
as
procedure rs_start;
procedure rs_middle;
procedure rs_stop(p_difference_threshold in number default 0);
end;
/
create or replace package body runstats_pkg
as
-- 这些全局变量用于纪录每次运行的耗用时间:
g_start number;
g_run1 number;
g_run2 number; procedure rs_start
is
begin
delete from run_stats;
insert into run_stats
select 'before', stats.* from stats;
g_start := dbms_utility.get_time;
end; procedure rs_middle
is
begin
g_run1 := (dbms_utility.get_time - g_start);
insert into run_stats
select 'after 1',stats.* from stats;
g_start := dbms_utility.get_time;
end; procedure rs_stop(p_difference_threshold in number default 0)
is
begin
g_run2 := (dbms_utility.get_time - g_start);
dbms_output.put_line('Run1 ran in'||g_run1||'hsecs');
dbms_output.put_line('Run2 ran in'||g_run2||'hsecs');
dbms_output.put_line('run 1 ran in '||round(g_run1/g_run2*100,2)||'%of the time');
dbms_output.put_line(chr(9)); insert into run_stats
select 'after 2', stats.* from stats;
dbms_output.put_line( rpad('Name',30)|| lpad('Run1',10)||
lpad('Run2',10)|| lpad('Diff',10));
for x in
(
select rpad(a.name,30)||
to_char(b.value - a.value,'9,999,999')||
to_char(c.value - b.value,'9,999,999')||
to_char(((c.value - b.value)-(b.value - a.value)),'9,999,999') data
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = 'after 2'
and (c.value - a.value) > 0
and abs((c.value - b.value) - (b.value - a.value)) > p_difference_threshold
order by abs((c.value - b.value)-(b.value - a.value))
) loop
dbms_output.put_line(x.data);
end loop; dbms_output.put_line(chr(9));
dbms_output.put_line('Run1 latches total versus runs -- difference and pct ');
dbms_output.put_line( lpad('Run1',10) || lpad('Run2',10) ||
lpad('Diff',10) || lpad('Pct',8));
for x in
(
select to_char(run1, '9,999,999')||
to_char(run2, '9,999,999')||
to_char(diff, '9,999,999')||
to_char(round(run1/run2*100,2), '999.99')||'%' data
from (
select sum(b.value - a.value) run1,
sum(c.value - b.value) run2,
sum((c.value - b.value) - (b.value - c.value)) diff
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = ‘after 2’
and a.name like 'latch%'
)
)loop
dbms_output.put_line(x.data);
end loop;
end;
end;
/

create or replace view stats
as
select 'STAT...'||a.NAME AS name, b.VALUE as value
from v$statname a, v$mystat b
where a.STATISTIC# = b.STATISTIC#
union all
select 'latch'||name as name, gets as value
from v$latch;

创建一张存储这些统计信息的小表:
create global temporary table run_stats
(
runid varchar2(15),
name varchar2(80),
value int
) on commit preserve rows;

使用测试:

set serveroutput on size 1000000;
exec runstats_pkg.rs_start;
exec pkg_mv_test.PR_MV_ENTRANCE;
exec runstats_pkg.rs_middle;
exec pkg_mv_test.PR_MV_ENTRANCE;
exec runstats_pkg.rs_stop(100000);

==========================================
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as zhangxsh SQL> set serveroutput on size 1000000;
SQL> exec runstats_pkg.rs_start; PL/SQL procedure successfully completed SQL> exec pkg_mv_test.PR_MV_ENTRANCE; PL/SQL procedure successfully completed SQL> exec runstats_pkg.rs_middle; PL/SQL procedure successfully completed SQL> exec pkg_mv_test.PR_MV_ENTRANCE;
SQL> exec pkg_mv_test.PR_MV_ENTRANCE; PL/SQL procedure successfully completed SQL> exec runstats_pkg.rs_stop; Run1 ran in5848hsecs
Run2 ran in3687hsecs
run 1 ran in 158.61%of the time Name Run1 Run2 Diff
STAT...cleanouts only - consis 175 176 1
STAT...transaction rollbacks 3 2 -1
STAT...immediate (CR) block cl 175 176 1
STAT...commit txn count during 368 369 1
STAT...commit batch/immediate 3 2 -1
STAT...commit immediate reques 3 2 -1
STAT...commit batch/immediate 3 2 -1
STAT...commit immediate perfor 3 2 -1
STAT...parse time cpu 6 5 -1
latchksuosstats global area 4 3 -1
latchobject stats modification 4 5 1
latchsort extent pool 7 8 1
latchktm global data 11 12 1
latchparameter list 0 1 1
latchJS mem alloc latch 1 0 -1
latchJS queue access latch 1 0 -1
STAT...redo synch writes 55,975 55,973 -2
STAT...session cursor cache co 2 0 -2
STAT...bytes sent via SQL*Net 2,120 2,118 -2
STAT...bytes received via SQL* 2,452 2,450 -2
latchobject queue header heap 7 9 2
latchcommit callback allocatio 0 2 2
latchjob_queue_processes param 3 1 -2
latchthreshold alerts latch 2 0 -2
STAT...immediate (CURRENT) blo 56,183 56,180 -3
STAT...parse time elapsed 8 5 -3
latchparameter table allocatio 5 2 -3
latchbuffer pool 3 0 -3
latchtransaction allocation 13 10 -3
latchhash table modification l 3 0 -3
STAT...user commits 111,948 111,944 -4
STAT...redo buffer allocation 15 11 -4
latchFOB s.o list latch 9 5 -4
latchFIB s.o chain latch 4 0 -4
latchparallel query alloc buff 8 4 -4
STAT...redo log space requests 16 11 -5
STAT...workarea executions - o 9 14 5
STAT...parse count (hard) 38 33 -5
latchmessage pool operations p 10 15 5
latchJS slv state obj latch 5 0 -5
STAT...user I/O wait time 9 3 -6
STAT...sorts (memory) 3 9 6
latchOS process 0 6 6
latchsession timer 22 16 -6
STAT...data blocks consistent 1,045 1,038 -7
STAT...rollbacks only - consis 1,045 1,038 -7
STAT...rows fetched via callba 40 32 -8
STAT...cursor authentications 33 25 -8
latchKMG MMAN ready and startu 20 12 -8
STAT...physical read total IO 27 18 -9
STAT...physical reads 27 18 -9
STAT...physical reads cache 27 18 -9
STAT...physical read IO reques 27 18 -9
STAT...write clones created in 82 72 -10
STAT...consistent changes 1,081 1,070 -11
STAT...application wait time 1 13 12
STAT...table fetch continued r 23 11 -12
latchresmgr group change latch 8 22 14
STAT...sorts (rows) 3,538 3,553 15
latchOS process allocation 20 35 15
latchpost/wait queue 57 40 -17
STAT...cluster key scans 182 163 -19
latchdummy allocation 4 23 19
latchresmgr:actses change grou 2 21 19
latchresmgr:actses active list 4 23 19
latchresmgr:free threads list 4 23 19
latchMemory Management Latch 20 0 -20
latchevent group latch 0 21 21
latchglobal KZLD latch for mem 0 21 21
STAT...opened cursors current 20 -2 -22
STAT...CR blocks created 1,126 1,104 -22
latchprocess allocation 0 23 23
latchprocess group creation 0 23 23
latchOS process: request alloc 0 23 23
latchloader state object freel 48 24 -24
STAT...table scans (short tabl 104 79 -25
latchchannel handle pool latch 3 28 25
latchactive checkpoint queue l 500 527 27
STAT...shared hash latch upgra 261 233 -28
STAT...index scans kdiixs1 85 57 -28
STAT...workarea memory allocat -3 26 29
latchactive service list 148 177 29
STAT...redo synch time 2 33 31
STAT...index fetch by key 172,087 172,056 -31
latchsession state list latch 8 41 33
latchfile cache latch 134 169 35
latchlibrary cache pin allocat 50 89 39
STAT...cluster key scan block 383 343 -40
latchcompile environment latch 41 83 42
latchuser lock 8 54 46
latchlibrary cache lock alloca 61 107 46
latchPL/SQL warning settings 25 77 52
latchkks stats 50 107 57
latchlibrary cache load lock 64 122 58
latchsequence cache 3 68 65
latchclient/application info 34 110 76
STAT...opened cursors cumulati 371 280 -91
STAT...session cursor cache hi 353 244 -109
STAT...parse count (total) 415 296 -119
latchchannel operations parent 534 656 122
STAT...redo log space wait tim 475 346 -129
STAT...change write time 277 146 -131
STAT...table fetch by rowid 4,168 4,018 -150
latchlist of block allocation 245 80 -165
latchJS queue state obj latch 486 252 -234
latchundo global data 546,976 547,262 286
STAT...calls to get snapshot s 281,447 281,127 -320
latchenqueues 2,432 2,063 -369
STAT...buffer is not pinned co 12,813 12,427 -386
STAT...IMU- failed to get a pr 8,907 8,493 -414
STAT...IMU pool not allocated 8,907 8,493 -414
STAT...cleanout - number of kt 1,566 1,133 -433
STAT...active txn count during 1,389 956 -433
latchSQL memory manager workar 1,303 868 -435
STAT...consistent gets - exami 342,647 342,116 -531
STAT...recursive cpu usage 1,704 1,003 -701
STAT...CPU used when call star 1,928 1,203 -725
STAT...CPU used by this sessio 1,928 1,203 -725
STAT...DB time 2,585 1,703 -882
STAT...hot buffers moved to he 1,208 0 -1,208
STAT...switch current to new b 1,264 0 -1,264
latchsession idle bit 263 1,700 1,437
STAT...calls to kcmgcs 2,339 803 -1,536
latchcache buffer handles 3,034 1,255 -1,779
latchsession allocation 7,506 9,570 2,064
latchlibrary cache lock 2,477 4,939 2,462
STAT...redo ordering marks 4,352 1,783 -2,569
STAT...rollback changes - undo 2,700 4 -2,696
latchcheckpoint queue latch 13,708 10,933 -2,775
STAT...calls to kcmgas 119,054 115,175 -3,879
STAT...free buffer requested 13,965 7,869 -6,096
STAT...table scan blocks gotte 118,393 112,276 -6,117
STAT...no work - consistent re 237,863 231,521 -6,342
STAT...consistent gets 582,789 575,657 -7,132
STAT...consistent gets from ca 582,789 575,657 -7,132
latchConsistent RBA 74,764 66,472 -8,292
latchmostly latch-free SCN 74,813 66,486 -8,327
latchlgwr LWN SCN 74,769 66,436 -8,333
STAT...messages sent 74,770 66,436 -8,334
latchcache buffers lru chain 41,576 30,955 -10,621
STAT...free buffer inspected 13,321 0 -13,321
latchobject queue header opera 56,580 36,948 -19,632
latchmessages 221,645 198,144 -23,501
latchredo writing 225,013 199,935 -25,078
latchredo allocation 441,395 415,945 -25,450
latchsimulator lru latch 108,398 78,460 -29,938
latchsimulator hash latch 110,063 79,545 -30,518
STAT...deferred (CURRENT) bloc 113,306 56,136 -57,170
STAT...physical read bytes 221,184 147,456 -73,728
STAT...physical read total byt 221,184 147,456 -73,728
STAT...IMU Flushes 103,035 3,033 -100,002
STAT...IMU commits 0 100,415 100,415
STAT...enqueue releases 336,854 224,702 -112,152
STAT...enqueue requests 336,854 224,702 -112,152
STAT...commit cleanouts succes 282,507 169,224 -113,283
STAT...commit cleanouts 282,514 169,231 -113,283
STAT...execute count 392,218 224,189 -168,029
STAT...recursive calls 956,477 787,573 -168,904
latchIn memory undo latch 669,714 466,685 -203,029
latchdml lock allocation 448,392 224,432 -223,960
latchenqueue hash chains 675,343 451,005 -224,338
STAT...buffer is pinned count 277,659 1,769 -275,890
STAT...redo entries 607,160 307,006 -300,154
STAT...db block gets from cach 1,041,178 735,660 -305,518
STAT...db block gets 1,041,178 735,660 -305,518
STAT...session logical reads 1,623,967 1,311,317 -312,650
STAT...session uga memory 392,880 65,464 -327,416
latchlibrary cache 792,505 462,068 -330,437
latchlibrary cache pin 788,056 455,048 -333,008
STAT...session uga memory max 516,332 138,512 -377,820
latchshared pool 705,607 233,465 -472,142
STAT...db block changes 1,448,639 852,288 -596,351
STAT...session pga memory 589,824 -131,072 -720,896
STAT...table scan rows gotten 9,698,389 8,915,734 -782,655
latchrow cache objects 1,707,517 30,186-1,677,331
latchcache buffers chains 6,709,233 4,968,781-1,740,452
STAT...session pga memory max 2,752,512 0-2,752,512
STAT...undo change vector size##############################
STAT...IMU undo allocation siz##############################
STAT...redo size ##############################
STAT...IMU Redo allocation siz########## 1,031,880##########
==========================================

【转载】tom的RUNSTATS测试工具的更多相关文章

  1. 转载:开发者眼中最好的 22 款 GUI 测试工具

    对于很多同学来说gui程序的测试是一个难点,所以我从网上转载了一篇关于gui测试的一篇文章,里面罗列的很多工具,大家可以尝试一下学习学习. 英文原文:22 best GUI testing tools ...

  2. 转载: 一、linux cpu、内存、IO、网络的测试工具

    来源地址: http://blog.csdn.net/wenwenxiong/article/details/77197997 记录一下 以后好找.. 一.linux cpu.内存.IO.网络的测试工 ...

  3. 数据库相关文章转载(2) MySQL自带的性能压力测试工具mysqlslap详解

    PS:今天一同事问我有木有比较靠谱的mysql压力测试工具可用.其实mysql自带就有一个叫mysqlslap的压力测试工具,还是模拟的不错的.下面举例说说.mysqlslap是从5.1.4版开始的一 ...

  4. IOZONE测试工具使用方法(转载)

    IOZONE主要用来测试操作系统文件系统性能的测试工具,该工具所测试的范围主要有,write , Re-write, Read, Re-Read, Random Read, Random Write, ...

  5. 渗透测试工具实战技巧 (转载freebuf)

    最好的 NMAP 扫描策略 # 适用所有大小网络最好的 nmap 扫描策略 # 主机发现,生成存活主机列表 $ nmap -sn -T4 -oG Discovery.gnmap 192.168.56. ...

  6. [转载]压力测试工具siege的用法

    压力测试工具siege 原文:http://blog.csdn.net/qingye2008/article/details/34500949 Siege是Linux下的一个web系统的压力测试工具, ...

  7. 移动应用开发测试工具Bugtags集成和使用教程【转载】

    前段时间,有很多APP突然走红,最终却都是樱花一现.作为一个创业团队,突然爆红是非常难得的机会.然并卵,由于没有经过充分的测试,再加上用户的激增,APP闪退.服务器数据异常等问题就被暴露出来,用户的流 ...

  8. github渗透测试工具库[转载]

    前言 今天看到一个博客里有这个置顶的工具清单,但是发现这些都是很早以前就有文章发出来的,我爬下来后一直放在txt里吃土.这里一起放出来. 漏洞练习平台 WebGoat漏洞练习平台:https://gi ...

  9. 渗透测试工具BurpSuite做网站的安全测试(基础版)

    渗透测试工具BurpSuite做网站的安全测试(基础版) 版权声明:本文为博主原创文章,未经博主允许不得转载. 学习网址: https://t0data.gitbooks.io/burpsuite/c ...

随机推荐

  1. USACO Sabotage, 2014 Mar 破坏阴谋(二分+贪心)

    一开始看完这题就有个想法: 只要把大于整个序列平均数的最大连续序列就是最优? 那把整个序列都减掉平均数 在做最大连续字序列和且记录长度? 仔细思考一下并不太对: 当子序列最大但长度较大 也许也比不上删 ...

  2. Js基础知识(作用域、特殊函数---自调、回调、作为值的函数)

    15.作用域 概念: 规定变量或函数的可被访问的范围和生命周期 分类: 全局作用域 -就是指当前整个页面环境: 局部作用域(函数作用域) -就是指某个函数内部环境 l 变量的作用域 全局变量 - 定义 ...

  3. web.xml中的url-pattern写法规则及匹配过程

    servlet和filter在javaEE开发中很常用,因此有必要知道web.xml文件映射的规则 1.  写法 ①完全匹配:以“/”开头,以字母(非“*”)结束    如:<url-patte ...

  4. Mysql command not found on mac pro

    export PATH=${PATH}:/usr/local/mysql/bin If you want this to be run every time you open terminal put ...

  5. Paper-[acmi 2015]Image based Static Facial Expression Recognition with Multiple Deep Network Learning

    [acmi 2015]Image based Static Facial Expression Recognition with Multiple Deep Network Learning ABST ...

  6. Stack Overflow大揭密:哪一种程序员工资最高?

    Stackoverflow在程序员之间可以說是无人不知无人不晓,甚至常有人开玩笑说:“如果stackoverflow倒闭了,全世界代码的产出率将下降一半以上”或许听起来有点夸张,但是不难想像这个网站在 ...

  7. day06-1 与用户交互以及格式化输出

    目录 Python的与用户交互 Python2的input和raw_input(了解) 格式化输出 占位符 format函数格式化字符串 f-string格式化(方便) Python的与用户交互 in ...

  8. router+x

    vue-router官方的路由管理器 包含的功能: ——绑定方法进行跳转   路由嵌套   写的不一样搜索的路由路径也不一样   二级路由   设置默认路由   导航守卫: 用于强制跳转或者取消的方式 ...

  9. Pyhton学习——Day58

    From表单验证 <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  10. Pyhton学习——Day39

    # CSS的常用属性# 1 颜色属性# <div style="color:rgb(255,0,0)">ppppp</div># 2 字体属性# font- ...