liangjz 发表于 2008-6-2 00:29:45

前端web分析工具pagetest核心技术

pagetest分析web 页面解析时间。PageTest为AOL 开放源码的,
可从http://pagetest.wiki.sourceforge.net/ 下载。

作用同ibm pagedetailer ,yahoo yslow。

pagetest用visual .net工程。

核心技术
1 Winsock2 SPI
参考
http://www.microsoft.com/msj/0599/LayeredService/LayeredService.aspx
http://www.vckbase.com/document/viewdoc/?id=643
或者windows 网络编程第14章winsock2服务提供者接口
如加载 SPI
wspStartup = new CAPIHook("mswsock.dll", "WSPStartup", (PROC)::WSPStartup_Hook, TRUE);               
                        nspStartup = new CAPIHook("mswsock.dll", "NSPStartup", (PROC)::NSPStartup_Hook, TRUE);       

主要函数如:
NSPLookupServiceBegin;NSPLookupServiceNext;NSPLookupServiceEnd
WSPSocket,WSPBind

2 WinInet


internetOpen

3IE插件技术

class ATL_NO_VTABLE CIEHook :
        public IObjectWithSiteImpl<CIEHook>,
        public IOleCommandTarget,
        public IDispEventImpl<1, CIEHook, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>,
           public IIEHook

STDMETHOD_(void,OnBeforeNavigate2)( IDispatch *pDisp, VARIANT * url, VARIANT * Flags, VARIANT * TargetFrameName, VARIANT * PostData, VARIANT * Headers, VARIANT_BOOL * Cancel );
        STDMETHOD_(void,OnDocumentComplete)( IDispatch *pDisp, VARIANT * url );
        STDMETHOD_(void,OnDownloadBegin)( VOID );
        STDMETHOD_(void,OnDownloadComplete)( VOID );
        STDMETHOD_(void,OnNavigateComplete)( IDispatch *pDisp, VARIANT * url );
        STDMETHOD_(void,OnNavigateError)( IDispatch *pDisp, VARIANT *url, VARIANT *TargetFrameName, VARIANT *StatusCode, VARIANT_BOOL *Cancel);
        STDMETHOD_(void,OnNewWindow)( IDispatch ** pDisp, VARIANT_BOOL *cancel );
        STDMETHOD_(void,OnQuit)( VOID );

        // IOleObjectWithSite Methods
        STDMETHOD(SetSite)(IUnknown *pUnkSite);


然后在IE浏览器初始化时做
void CIEHook::InstallHooks(void)
{
        // load ourselves to make sure we stay loaded until the browser goes away
        // otherwise some of the API hooks will crash
        LoadLibrary(_T("Pagetest.dll"));

        // hook the browser wndProc (to supress crashes)
        #ifndef DEBUG
        if( !dispatch_hook )
                dispatch_hook = new CAPIHook("user32.dll", "DispatchMessageW", (PROC)::DispatchMessageW_hook, TRUE);
        #endif
       
        // hook winsock
        WinsockInstallHooks();
       
        // hook wininet
        WinInetInstallHooks();
}

4 windows精确计时

                EnterCriticalSection(&cs);
                QueryPerformanceCounter((LARGE_INTEGER *)&lastActivity);
                LeaveCriticalSection(&cs);

5 各个环节的衔接
这个才是重中之重。

iori 发表于 2008-6-2 09:10:00

看了,学习

angelwamy 发表于 2008-6-2 09:55:32

学习了,:lol

bzcyer 发表于 2008-6-2 09:57:17

一看到指针都就晕了

susieliu 发表于 2008-7-17 11:22:49

请问,我安装 以后怎么启动部了IE 呢?
点了IE 图标,弹出来的窗口一闪就没了

feier_y 发表于 2008-7-22 14:12:02

网址页面无法显示啊,楼猪

liangjz 发表于 2008-7-28 19:28:27

sourceforge.net这段时间国内访问很不正常:)

copyjuzi 发表于 2011-5-30 11:46:37

我用过这个工具,只能在ie6下能正常使用,如果是ie7或8等,打开ie后就无法正常访问网站了
页: [1]
查看完整版本: 前端web分析工具pagetest核心技术