AQtime学习资料(6)

2019-04-23 18:58

d).F5运行:

a)当不点击Start按钮时,AQtime没有记录任何数据; b)依次点击start按钮和stop按钮后,得到如下结果:

2.Using Triggers:

Triggers并不是触发器,它的使用方法与Areas类似,都是用来控制程序的哪一部分需要Profiling。所不同的是:

Areas控制的是哪一部分代码需要Profiling;而Triggers控制哪一部分执行路径需要Profiling. 举例说明:

部分测试代码:

void CProfilerTestDlg::OnButStart() {

// TODO: Add your control notification handler code here

GetDlgItem(IDC_STATE)->SetWindowText(\当前状态:运行中...\SetTimer( 1 , 100 , NULL); }

void CProfilerTestDlg::OnButStop() {

// TODO: Add your control notification handler code here

GetDlgItem(IDC_STATE)->SetWindowText(\当前状态:停止\KillTimer( 1 ); }

void CProfilerTestDlg::OnTimer(UINT nIDEvent) {

// TODO: Add your message handler code here and/or call default if ( nIDEvent == 1 ) {

m_lSum += 1; }

CDialog::OnTimer(nIDEvent); }

1).使用Areas:

在Areas中定义区域Button,并将CProfilerTestDlg::OnButStart函数加入区域下,去除Full Check by Lines复选框;:

运行程序,并点击Start按钮,得到结果:

2).使用Trigger:

勾选Full Check by LInes,并添加Trigger如图:

同样运行程序,并点击start按钮,得到结果:

对比以上两个结果图,可以发现Areas只记录了OnButStart函数的执行情况;而Trigger不但记录了OnButStart而且记录了其子函数的调用情况。

3)off-trigger的用法:

当建立一个Trigger并设置为OFF状态时,所属这个Trigger的函数或模块将不被记录,并且其子函数的调用也不会被记录。举例:

Proc_B is an off-trigger routine, profiling is currently enabled and either Full Check by Routines, or Full Check by Linesis used:

Proc_A;

Proc_B // off-trigger routine

Proc_D; // Proc_D and Proc_E are child routines of Proc_B, Proc_E; // that is, they are called within Proc_B.

// Proc_D and Proc_E are not profiled. Proc_C;

3.Setting Up Triggers

Triggers的高级选项中的配置说明: 1)Pass Count:

该选项允许某一函数或模块在被调用N次后再进行Profiling.(N默认为0,即第一次调用就开始Profiling).比如在上面的ProfilerTest程序中,如果设置Pass Count为3,那么意味着当点击start按钮第四次时,Profiling才真正开始.通过此选项可以跳过初始化的一些操作后再进行Profiling. 2)Work Count:

该选项用来设置Trigger起作用的次数。通过该选项可以限制一些我们已经知道的函数调用信息。 3)Cycling:

是否执行Pass Count->Work Count的循环执行,默认情况下不选中。此功能可以用在函数被周期性调用的情况下。举例说明:

按照以上设置后: 当点击Start按钮第2当点击Start按钮第5当点击Start按钮第6当点击Start按钮第8

次时,此时没有Profiling;

次时,Profiling记录到OnButStart函数被调用了3次; 次时,仍然只记录了OnButStart函数被调用3次; 次时,Profiling记录到OnButStart函数被调用了4次;

4)For All Threads:

影响调用Count计数的两种方式:所有线程和Trigger所在的线程。For All Threads选中的状态下,所有线程对函数调用的计数都会产生影响。

Remember that, whether or not calls are counted over all threads, triggers only act on their own thread. 多线程举例说明: #include #include #include

int CalSum( int iCount ) {

int sum=0;

for(int i=1; i <= iCount; i++)

sum=sum+i; return sum; }

DWORD WINAPI funA(LPVOID lp) {

int iResult;

iResult = CalSum( 100 );

printf(\

return 0; }

DWORD WINAPI funB(LPVOID lp) {

int iResult;

iResult = CalSum( 101 );

printf(\

return 0; }

void main() {

HANDLE a[2];

DWORD dwT,dwY;

a[0]=CreateThread(NULL,0,funA,0,0,&dwT); a[1]=CreateThread(NULL,0,funB,0,0,&dwY);

WaitForMultipleObjects(2,a,TRUE,50000);

CloseHandle(a[0]); CloseHandle(a[1]); }

a).勾选For All Threads的情况:

按照上图所设置的Trigger,CalSum函数只要被任何线程调用过一次后就不再Profiling了。结果如图:

b).不勾选For All Threads的情况:

4.By lines 和 By Routine的试验

在Area中可以设置两种测试级别:by lines 和 by routine。此选项只对Performance 和 Coverage有效。 测试程序:

#include \

class animal {

public:

virtual void shout() { printf( \};

class dog :public animal {


AQtime学习资料(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:11-050职业技能鉴定指导书-变电站值班员(2)-高级技师

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: