与其临渊羡鱼,不如退而结网!

CLT使用说明

上一篇 / 下一篇  2008-12-24 08:23:43 / 个人分类:其他

一、使用CLRProfiler
.V$Z1q5U8YvJ0文件CLRProfiler.EXE是个自解压文件。运行该文件,指定目录并选择unzip即可。然后,在解压目录中,找到CTLProfiler\Binaries\x86\CLRProfiler.exe,双击即可运行,显示CLRProfiler界面。
 
二、CLRProfiler界面
t9x#h wugB5FO/ga0
  • Start Application:单击该按钮则启动 打开 对话框。选择要测试的应用程序。
  • Kill Application:单击该按钮则结束测试的应用程序。同时,该按钮也会自动生成日志文件,并加载到CLRProfiler中。
  • Show Heap now:单击该按钮则应用程序产生heap dump,并以Heap Graph显示结果。
  • The Profiling active:
  • Profiling active:Allocations和Calls:Calls复选框是可以关闭一些特定的日志功能。这样设置可以提高CTLProfiler的性能。
1.菜单操作方式
    在File菜单下有如下几项二级菜单:Open Log FileProfile Application、Profile ASP.NETProfile ServiceSave Profile AsSet Parameters(设置命令行参数和工作目录)Exit。这些选项都比较直观,此处不再做介绍。
          在Edit菜单下只有Font一个二级菜单。用户可以通过该菜单改变所有视图的字体。
         在View菜单下有多个二级菜单:Summary,16个按不同方式组织的图表,以及compare with(日志比较)。其中,Summary提供被测程序的静态统计数据,也可以通过按钮某个了解详细信息。
51Testing软件测试网lX"M%FS#uV
2. 命令行操作方式
    除了菜单方式以外,还可以批处理模式来生成日志文件。命令行生成日志的用法如下:

 CLRProfiler [-o logName][-na][-nc][-np][-p exeName [args]]51Testing软件测试网#PT#].VZD+?2RM

 

~PFx wgS4@0

·         –o     输出的日志文件51Testing软件测试网DZB)U"e Q+F

·         –p     待执行的应用程序

A@.UK6D|/QY J0

·         –na     设置CLRProfiler不记录分配情况51Testing软件测试网7EH k0s @RN

·         –nc     设置CLRProfiler不记录特定的日志

|)c_]/@0

·         –np    tells CLRProfiler to start with profiling off (useful when the profiled application turns profiling on for interesting code sections)

#dh q)eQA:q [0

 

/fWje J A f2U0

也可以在CLRProfiler目录下,执行 CLRProfiler.exe -?命令,用于查询相关参数的用法,例如:

_fA6hR])~N0

C:\CLRProfiler>CLRProfiler.exe -?

BA E]eG-Wq:N0

 

,d@4y}yt0

三、垃圾收集及其如何反应到视图的问题

P(L'DD9aq0

注:无内存泄露的被测程序,在Time line图中,应显示规则的锯齿状图;如果有内存泄漏则将呈现一个逐渐升高的锯齿状,如下图:51Testing软件测试网\ _Z(FZ4x a

U0B@,| X*o0

 51Testing软件测试网 E+LE n6V:I M iD`I

 51Testing软件测试网1Er$B)b K;HPW J|

1.程序分配过多

|6}3ZGy/i0

    有时,问题的原因很简单:就是程序中分配过多的内存。如果内存存活期很短,反应不会很明显。因为很快垃圾回收器就做了回收,看起来好像这个程序只比预期慢一点而已。

ko3lT@0

2.持有内存时间过长51Testing软件测试网4^|wAc7p&el g1x

    另一个普遍的问题就是持有内存时间过长。此时,内存不必是永久持有(这将是泄漏),但是其持有时间比实际需要的时间长的情况。51Testing软件测试网JM}py){4S

3.捕获内存泄露51Testing软件测试网2|$Ys k7G4])p"q3J

 

bE RA+{NB-{W0

四、CLRProfiler API51Testing软件测试网X.vg$e b

    如果想要在被测程序控制CLRProfiler的话,可以通过与ProfilerOBJ.dll通信来完成。51Testing软件测试网{j+\;Rk

 

E \fG"Eb0

五、通过命令行生成报告、51Testing软件测试网X!R$G4]i

    当使用CLRProfiler来测试时,,我们不需要考虑回归测试,它可以进行。我们可以在CLRProfiler下运行被测程序并生成一些基线报告,当程序更新后,重新再在CLRProfiler下运行新程序并生成报告。然后将新生成的报告和基线报告进行对比,即可。51Testing软件测试网T(q!qq f-Gs

        对于回归测试来说,首先要为CLRProfiler设置将要运行的程序、日志文件保存目录等命令行参数。

8yMFX`{B@)J1{0

         该命令行语法与命令行操作方式一致:51Testing软件测试网%iGUE"h;XoWu

Bl:QN a5W H3G0

 CLRProfiler [-o logName][-na][-nc][-np][-p exeName [args]]

zk:Z-[ pCw-R%A0

 51Testing软件测试网u/Q#h)GT

·         –o     输出的日志文件51Testing软件测试网F'\)\,Hi.b,Xg2J

·         –p     待执行的应用程序

5b8k8q/_&`0

·         –na     设置CLRProfiler不记录分配情况51Testing软件测试网e;Ax |"Z,e](N

·         –nc     设置CLRProfiler不记录特定的日志51Testing软件测试网 G4doUQ w,g

·         –np    tells CLRProfiler to start with profiling off (useful when the profiled application turns profiling on for interesting code sections)

q"Qv~~+gy~ w0

 51Testing软件测试网OH ?&k` [l3Yz~

六、CLRProfiler的内部配置

fw;tD3E jG0

1.环境变量51Testing软件测试网;z)D"[9SY3?BmN.D

    为了触发和控制的目的,CLRProfiler需要传递一些环境变量给处理进程。下表列出了具体变量值和解释:

~o6x0j*o*I c5M0

Variable and value

yER8lj%W0

Explanation51Testing软件测试网!|D` `/\o6Q]

Cor_Enable_Profiling=0x1

AMwf7dy&M0

Triggers profiling by the CLR.51Testing软件测试网Zi __`,mQ

COR_PROFILER={8C29BC4E-1F57-461a-9B51-1200C32E6F1F}51Testing软件测试网#CZ$j's9eb g3\

GUID of the profiler DLL to load.

`(^*u8F4m"g2s+IF0

OMV_SKIP=051Testing软件测试网 w8n"~^3A:\n)[7p2j

Number of initial object allocations to skip.

SI5MqI%M0

OMV_FORMAT=v2

/c$y [&k$WjA0

Version of log file format to write.51Testing软件测试网9JE+kVG{7k

OMV_STACK=1

DFd2J(qSd4v0

Tracks the call stack of the profiled application.51Testing软件测试网;iS8`a+r

OMV_DynamicObjectTracking=0x151Testing软件测试网!tzi)yM0p F

Allows profiling to be switched on and off.51Testing软件测试网y;W/n L~'y L8d

OMV_PATH=C:\WINDOWS\Temp

;tz%V'i9] P\0

Indicates where to put the log file.51Testing软件测试网.J9os;{wap

OMV_USAGE=both

u`XY8d$g!R0

Tracks both allocations and calls – other legal values are “trace” (just calls) and “objects” (just allocations).

Il4U$j8[8FfH0

OMV_INITIAL_SETTING=0x351Testing软件测试网&`,rBI i0H6?

Reflects the setting of the Profile: Allocations and Profile: Calls checkboxes.

:v/_(h'SJHQ krZ0

n#Ac/X#]O#P@j0

51Testing软件测试网f@F4_q`cul

2h~$e2AiVU-qA.Pm051Testing软件测试网\ E"t7]%l YzIWj&k

51Testing软件测试网 syz4W3__2N:e W

2.日志文件格式51Testing软件测试网/J~6B?H+z7S

日志文件是简单的以行为导向的txt文件。每行都有以一个单字符开头。这个单字符是该行描述的功能、类型、分配、调用等等的类型。51Testing软件测试网'lEi;Rn ?.ig


TAG: 其他

 

评分:0

我来说两句

Open Toolbar