搜狗音乐盒的启动(程序初始化)性能测试
一、测试条件:测试内容描述:记录从启动搜狗音乐盒,到主程序界面的初始化工作完成所消耗的时间。程序版本:搜狗音乐盒v1.1.0.47(Release)
测试环境:WinXP SP2 + Office2007
测试工具:AQtime v5.40
起始时间点:AfxWinMain的入口
终止时间点:CSohuplayerDlg::OnInitDialog()执行完毕退出
硬件环境:
CPU2 * Intel(R) Pentium(R) D CPU 3.00GHz, Frequency: ~2992 MHz
内存2095144 Kb
进程列表:
进程名称备注
Rtvscan.exe
AQtime.exeAQtime v5.40
ONENOTE.EXEOFFICE 20007 NOTE
Svhost.exe
OUTLOOK.EXEOUTLOOK
TM.EXETM2008
system
Sqlservr.exe
Msnmsgr.exeMSN
Csrss.exe
MSDEV.EXEVisual C++ 6.0
VPTray.exe
ccApp.exe
Smss.exe
Explorer.exe
ONENOTEM.EXE
Winlogon.exe
Spoolsv.exe
SavRoam.exe
Smax4pnp.exe
Svhost.exe
TSVNCache.exeSVN v1.5
Lsass.exe
Svchost.exe
Nutsrv4.exe
Svchost.exe
Services.exe
ccSetMgr.exe
TXPlatform.exe
DefWatch.exe
Sqlbrowser.exe
Usnsvc.exe
Svchost.exe
Alg.exe
Ctfmon.exe
ccEvtMgr.exe
Conime.exe
二、测试步骤:1.配置VC6的编译信息:1).SetActive Project Configuration: 2).在Project Settings | C/C++选项中,设置Debuginfo为Program Database.3).在Project Settings | Link,选择Category为General,将Generate debug info复选框选中. 4).在Project Settings | Link,选择Category为Customize,在Program database name中填入PDB文件路径: 5).在Project Settings | Link,选择Category为Debug,勾选Debuginfo;去除Separate types。至此准备工作已经完成,编译源代码。2.配置AQTIME:1).在AQtime中添加待测试程序和模块: 2).配置Area和Actions: 3.运行并得到测试结果: AQtime Performance Profiler
Session information
Started:2008-7-8 20:50:20
Ended:2008-7-8 20:50:24
Execution time:00:00:03:891
Routines analyzed:6197
Routines executed:694
Total number of routine calls:8000
Total value of 'Elapsed Time': 1608.46
Performance hot spots All Threads Worst performance (body only):
CThread<CAdWorkThread>::tfunc207.50
CSohuplayerApp::InitInstance201.74
CDBOperater::InitLocalDataBase2176.80
CDownloadThreadBase::winGetFileFromSvr126.72
CDBOperater::GetCreateFields126.50
CWMPPlayer4::Create87.57
CThread<CDownloadThreadBase>::tfunc78.68
CSohuplayerDlg::InitSkinMgr69.66
CResourceHolder::LoadBitmapA63.38
CWndContainer::OnCreate55.74
Run settings
Profiling mode:Normal
Host Application:
Parameters:
Work Directory:
Profiler options
Active counter: Elapsed Time
Thread model: Win32 Threads
Profile <Root> routine: False
Profile Entire .NET Code: None
Disable inlining: False
Profile .NET runtime: False
System information
Operating system:Microsoft Windows XP Service Pack 2 (version: 5.1 Build 2600)
Total physical memory:2095144 Kb
Available physical memory:1322132 Kb
Total virtual memory:2097024 Kb
Available virtual memory:1800944 Kb
Processor type:Intel(R) Pentium(R) D CPU 3.00GHz, Frequency: ~2992 MHz.
Number of processors:2
调用函数执行时间截图:(部分) 函数调用关系截图:(部分) 三、测试结果报告:1.程序执行时间超过100毫秒的函数分别是:
函数名执行时间包含子函数的执行时间备注
Cthread<CAdWorkThread>::tfunc207.50毫秒208.60毫秒主线程工作函数,忽略
CSohuplayerApp:InitInstance201.74毫秒1191.30毫秒
CDBOperater::InitLocalDataBase2176.80毫秒306.70毫秒
CDownloadThreadBase::WinGetFileFromSvr126.72毫秒126.78毫秒发送HTTP请求等待时间
CDBOperater::GetCreateFields126.50毫秒126.54毫秒
2.因为主程序的初始化工作都是在CSohuplayerApp::InitInstance中完成的,所以由此函数作为分析入口,逐步展开分析: 由上图结果可以看到,InstallCrashReport()在正式发布版本中是不编译执行的,可忽略;AfxOleInit时间消耗并不大,可忽略;重点分析intnRespoinse = dlg.DoModal(),即音乐盒主窗口的实例化操作CSohuplayerDlg::OnInitDialog函数。 3)在AQTIME的Editor面板中,进一步分析主窗口初始化函数CSohuplayerDlg::OnInitDialog的各条语句运行时间,得到如下图: 找到2个时间消耗较大的函数:CreateChildWnd()和CDBOperater::Instance()->InitLocalDataBase(&m_db)1).首先分析CDBOperater::InitLocalDataBase,因为其函数内部只是进一步地调用CDBOperater:InitLocalDataBase2,所以查看CDBOperater:InitLocalDataBase2的各条语句执行时间信息: BOOLCDBOperater::InitLocalDataBase2(CDatabase* pdb)// HitCount : 1//Time : 176.80//Time with Children : 306.70{CCriticalSectionGuardguard(&m_csDBGuard); m_pdb = pdb;DWORD dwAttr =::GetFileAttributes(m_strDBFile);if ( 0xFFFFFFFF ==dwAttr ){if ( FALSE ==CreateMultiDirectory(m_strDBFile) ){return FALSE;}……else{::CoInitialize(NULL);CString strCNN =_T("Provider=Microsoft.JET.OLEDB.4.0;Data source = ");strCNN +=m_strDBFile;_CatalogPtrpCatalog = NULL;pCatalog.CreateInstance(__uuidof(Catalog));if ( NULL ==pCatalog ){::CoUninitialize();return FALSE;}pCatalog->PutActiveConnection((LPCTSTR)strCNN);//耗时115.59毫秒 if (pCatalog->Tables->Count > 0 ){_variant_tvIndex((short)0);_TablePtr pTable =pCatalog->Tables->GetItem(vIndex);if ( NULL ==pTable ){::CoUninitialize();return FALSE;} //"JetOLEDB:Compressed UNICODE Strings" can throw exception, ADO & MS Bug!!!ChangeColumnProperty(pTable,"Song","JetOLEDB:Allow Zero Length",true);ChangeColumnProperty(pTable,"Artist","JetOLEDB:Allow Zero Length",true);ChangeColumnProperty(pTable,"Album","JetOLEDB:Allow Zero Length",true);ChangeColumnProperty(pTable,"Type","JetOLEDB:Allow Zero Length",true);}::CoUninitialize(); m_pdb->OpenEx(m_strDsn,CDatabase::noOdbcDialog);//耗时37.66毫秒 CList<CString,CString>listCreateFields;GetCreateFields(&listCreateFields);//耗时126.54毫秒
if (listCreateFields.GetCount() > 0 ){CreateNewFields(&listCreateFields);}….分析:可以看到时间消耗主要在上面粗体字显示的三个函数。pCatalog->PutActiveConnection((LPCTSTR)strCNN)是调用的第三方XTPCalendarADO的方法,所以没有办法进一步追踪;m_pdb->OpenEx(m_strDsn,CDatabase::noOdbcDialog)是调用MFC中CDataBase的方法,因此也没有办法进一步追踪。而GetCreateFields(&listCreateFields)可以进一步追踪: GetCreateFields(&listCreateFields):
// HitCount : 1//Time : 156.56//Time with Children : 156.59voidCDBOperater::GetCreateFields(CList<CString,CString>* plistCreateFields){plistCreateFields->AddTail("Idx");…... CRecordsetrs(m_pdb);CODBCFieldInfo fi;//144.32毫秒
rs.Open(CRecordset::forwardOnly,"SELECT* FROM AudioIndex WHERE Type = \'aaa\'",CRecordset::readOnly);int nFCount =rs.GetODBCFieldCount();while(nFCount){…….nFCount--;}rs.Close();}分析:时间主要消耗在CODBCFieldInfo类实例化的对象fi的过程中。 2).其次分析CreateChildWnd函数: BOOLCSohuplayerDlg::CreateChildWnd()// HitCount : 1//Time : 11.87//Time with Children : 382.62…...m_dlgPlayer.Create(NULL, NULL,WS_CHILD|WS_VISIBLE, CRect(0, 0, 0, 0), this, IDC_PLAYER_WND_ID);//耗时115.15毫秒……m_dlgAudioGroup.Create(IDD_MUSICCENTER_DIALOG,&m_ctrlTab);//耗时262.04毫秒….} 分析:· m_dlgPlayer是CSohuPlayer的成员变量,执行m_dlgPlayer.create即实例化m_dlgPlayer的过程。查看CDlgPlayer的子函数调用关系图,可以看到最终时间消耗在创建WMP控件的过程中。 · 消耗在m_dlgAudoGroup.Create的262.04毫秒中,有250.21毫秒是消耗在CMusicCenterDlg::OnInitDialog过程中,如下: BOOLCMusicCenterDlg::OnInitDialog()// HitCount : 1//Time : 0.99//Time with Children : 250.21{m_downloadListManage.SetMusicCenter(this);m_auditionManage.SetMusicCenter(this);m_playListManage.SetMusicCenter(this);m_searchListManage.SetMusicCenter(this);m_playmusicManage.SetMusicCenter(this); CMusicCenterDlgBase::OnInitDialog();
::ShowWindow(GetDlgItem(IDC_CHECK_SONG)->GetSafeHwnd(),SW_HIDE);DWORD dwSL = 1;CPublicFun::GetSearchSL(dwSL);((CButton*)GetDlgItem(IDC_CHECK_SONG))->SetCheck(dwSL); …..
InitMusicCenter(); //56.12毫秒,占总时间消耗.22.43%
InitMusicPlayInfo();//2.18毫秒,占总时间消耗0.87%
InitMusicLyric();//47.20毫秒,占总时间消耗18.86%
InitMusicButtonEx();//52.59毫秒,占总时间消耗21.02%
InitMusicSlider();//18.26毫秒,占总时间消耗7.30%
InitMusicList();//10.43毫秒,占总时间消耗4.17%
InitMusicExplorer();//55.78毫秒,占总时间消耗22.29%
…..四、结果:CDBOperater:InitLocalDataBase2函数内的pCatalog->PutActiveConnection((LPCTSTR)strCNN),影响启动时间较大,有优化的可能。 搜狗音乐盒网络歌曲列表加载性能测试2008年7月9日10:25一、测试条件:测试内容描述:当程序运行时,记录用户点击程序窗口左侧的"音乐排行榜"->"热门单曲",到歌曲列表被插入到列表控件的时间(不包含界面刷新的时间)。
程序版本:搜狗音乐盒v1.1.0.47(Release)
测试环境:WinXP SP2 + Office2007
测试工具:AQtime v5.40
起始时间点:CPersistentTreeCtrl::OnSelchangeingTree入口
终止时间点:CMusicCenterDlg::LoadSearchUrlFromBuffer出口
硬件环境:
CPU2 * Intel(R) Pentium(R) D CPU 3.00GHz, Frequency: ~2992 MHz
内存2095144 Kb
进程列表:
进程名称备注
Rtvscan.exe
AQtime.exeAQtime v5.40
ONENOTE.EXEOFFICE 20007 NOTE
Svhost.exe
OUTLOOK.EXEOUTLOOK
TM.EXETM2008
system
Sqlservr.exe
Msnmsgr.exeMSN
Csrss.exe
MSDEV.EXEVisual C++ 6.0
VPTray.exe
ccApp.exe
Smss.exe
Explorer.exe
ONENOTEM.EXE
Winlogon.exe
Spoolsv.exe
SavRoam.exe
Smax4pnp.exe
Svhost.exe
TSVNCache.exeSVN v1.5
Lsass.exe
Svchost.exe
Nutsrv4.exe
Svchost.exe
Services.exe
ccSetMgr.exe
TXPlatform.exe
DefWatch.exe
Sqlbrowser.exe
Usnsvc.exe
Svchost.exe
Alg.exe
Ctfmon.exe
ccEvtMgr.exe
Conime.exe
二、测试步骤:1.配置VC6的编译信息:2.配置AQTIME:3.运行并得到测试结果:AQtime Performance Profiler
Session information
Started:2008-7-9 16:09:19
Ended:2008-7-9 16:09:27
Execution time:00:00:08:031
Routines analyzed:6197
Routines executed:92
Total number of routine calls:4364
Total value of 'Elapsed Time': 40.79
Performance hot spots All Threads Worst performance (body only):
CSohuSkinManagerSchemaDefault::DrawThemeBackground7.70
CPersistentListCtrl::DrawColorBK5.13
CPersistentHeaderCtrl::OnPaint4.14
CPersistentListCtrl::DoListMiniItemSize3.61
CPersistentListCtrl::SetMusicListType3.47
CMusicCenterDlg::HideExplorerWebPage3.26
CPersistentListCtrl::DelAllColumn2.73
CPersistentListCtrl::OnPaint2.31
CPublicFun::GetRegistryInt1.34
CPersistentListCtrl::OnSize1.19
Worst performance (with children):
Routine with max HitCount:
Win32 Thread 4920
Run settings
Profiling mode:Normal
Host Application:
Parameters:
Work Directory:
Profiler options
Active counter: Elapsed Time
Thread model: Win32 Threads
Profile <Root> routine: False
Profile Entire .NET Code: None
Disable inlining: False
Profile .NET runtime: False
System information
Operating system:Microsoft Windows XP Service Pack 2 (version: 5.1 Build 2600)
Total physical memory:2095144 Kb
Available physical memory:1281352 Kb
Total virtual memory:2097024 Kb
Available virtual memory:1827216 Kb
Processor type:Intel(R) Pentium(R) D CPU 3.00GHz, Frequency: ~2992 MHz.
Number of processors:2
三、分析: 网络歌曲列表加载的时间主要集中在网络传输速度,而程序本身的执行时间所占比率非常短。提升此功能的突破点主要在提升网络传输的速度。 搜狗音乐盒界面刷新性能测试2008年7月9日10:25一、测试条件:测试内容描述:当程序运行时,用户随意放大和缩小窗体,记录绘图函数所用的平均时间。
程序版本:搜狗音乐盒v1.1.0.47(Release)
测试环境:WinXP SP2 + Office2007
测试工具:AQtime v5.40
硬件环境:
CPU2 * Intel(R) Pentium(R) D CPU 3.00GHz, Frequency: ~2992 MHz
内存2095144 Kb
进程列表:
进程名称备注
Rtvscan.exe
AQtime.exeAQtime v5.40
ONENOTE.EXEOFFICE 20007 NOTE
Svhost.exe
OUTLOOK.EXEOUTLOOK
TM.EXETM2008
system
Sqlservr.exe
Msnmsgr.exeMSN
Csrss.exe
MSDEV.EXEVisual C++ 6.0
VPTray.exe
ccApp.exe
Smss.exe
Explorer.exe
ONENOTEM.EXE
Winlogon.exe
Spoolsv.exe
SavRoam.exe
Smax4pnp.exe
Svhost.exe
TSVNCache.exeSVN v1.5
Lsass.exe
Svchost.exe
Nutsrv4.exe
Svchost.exe
Services.exe
ccSetMgr.exe
TXPlatform.exe
DefWatch.exe
Sqlbrowser.exe
Usnsvc.exe
Svchost.exe
Alg.exe
Ctfmon.exe
ccEvtMgr.exe
Conime.exe
二、配置AQTIME的Profiler参数: 三、测试结果:(单位是微秒) 四、分析:1.CPublicFun::CreateDirectoryExA: 由上面调用关系图可以看到在每次执行CPersistentListCtrl::CustomDrawSearhList时,都会执行CPublicFun::GetTempMusicPath,此函数的作用是获取下载音乐临时目录,如果不存在则创建。推测这里是一个性能瓶颈点。 Static CString strTmpMusic =CPublicFun::GetTempMusicPath()用法在整个工程中有26处调用,分别是D:\Project\sohuplayer\LoginDlgVC6Dlg.cpp(1070):D:\Project\sohuplayer\MCAuditionManage.cpp(68): D:\Project\sohuplayer\MCAuditionManage.cpp(232):D:\Project\sohuplayer\MCDownloadListManage.cpp(209):D:\Project\sohuplayer\MCDownloadListManage.cpp(633):D:\Project\sohuplayer\MusicCenterDlg.cpp(924):D:\Project\sohuplayer\MusicCenterDlg.cpp(7498):D:\Project\sohuplayer\MusicCenterDlg.cpp(7874):D:\Project\sohuplayer\MusicCenterDlg.cpp(8911):D:\Project\sohuplayer\MusicCenterDlg.cpp(8983):D:\Project\sohuplayer\MusicCenterDlg.cpp(9018):D:\Project\sohuplayer\MusicCenterDlg.cpp(9928):D:\Project\sohuplayer\MusicCenterDlg.cpp(11404): D:\Project\sohuplayer\MusicCenterDlg.cpp(12448): D:\Project\sohuplayer\MusicCenterDlg.cpp(13156): D:\Project\sohuplayer\PersistentListCtrl.cpp(761):D:\Project\sohuplayer\PersistentListCtrl.cpp(1061):D:\Project\sohuplayer\PersistentListCtrl.cpp(1090):D:\Project\sohuplayer\PersistentListCtrl.cpp(2542):D:\Project\sohuplayer\PersistentListCtrl.cpp(2745):D:\Project\sohuplayer\PersistentListCtrl.cpp(2906):D:\Project\sohuplayer\PersistentListCtrl.cpp(4290):D:\Project\sohuplayer\PersistentListCtrl.cpp(5385):D:\Project\sohuplayer\PersistentListCtrl.cpp(6129):D:\Project\sohuplayer\Public.cpp(237):D:\Project\sohuplayer\WndContainer.cpp(993): 学习,感谢分享。
是一个现实实际应用例子。 看着好复杂
页:
[1]