Webpagetest webpage front-end performance testing tools and implementation analysis

Source: Internet
Author: User
Tags webpagetest

Webpagetest was originally developed and used internally by AOL. Later, it was open-source on Google Code and is a very good browser performance testing tool. Online version http://www.webpagetest.org

Google Code: http://code.google.com/p/webpagetest/

Deploy webpagetest private instance reference

Http://testing.etao.com/node/303

Http://testing.etao.com/node

The client implementation analysis provided by the author is as follows: 

The networking stack on Windows from a browser's perspective

Function Interception

The key to how webpagetest works is its ability to intercept arbitrary function CILS

And inspect or alter the request or response before passing it on to the original imple-mentation (or choosing not to pass it on at all). Luckily someone else did most of

Heavy lifting and provided a nice open source Library (http://newgre.net/ncodehook) that

Can take care of the details for you but it basically works like this:

• Find the target function in memory (trivial if it is exported from a DLL ).

• Copy the first several bytes from the function (making sure to keep x86 instructions

Intact ).

• Overwrite the function entry with a JMP to the new function.

• Provide a replacement function that includes des the bytes copied from the original

Function along with a JMP to the remaining code.

It's pretty hairy stuff and things tend to go very wrong if you aren't extremely careful,

But with well-defined functions (like all of the Windows APIs), you can pretty much

Intercept anything you 'd like.

One catch is that you can only redirect cballs to code running in the same process as

Original function, which is fine if you wrote the code but doesn't help a lot if you are

Trying to spy on software that you don't control which leads us...

Code Injection

Lucky for me, Windows provides several ways to inject arbitrary code into processes.

There is a good overview of several different techniques here: http://www.codeproject

. Com/KB/Threads/winspy. aspx, and there are actually more ways to do it than that

It covers the basics. Some of the techniques insert your code into every process but I

Wanted to be a lot more targeted and just instrument the specific browser instances

That we are interested in, so after a bunch of experimentation (and horrible failures), I

Ended up using the createremotethread/loadlibrary technique which essential lets

You force any process to load an arbitrary DLL and execute code in it (assuming you have

The necessary rights ).

Resulting browser Architecture

Get the code

Since webpagetest is under a BSD license you are welcome to reuse any of the Code

Whatever purposes you 'd like. The project lives on Google code here: (http://code.goo

Gle.com/p/webpagetest/) and some of the more interesting files are:

• Winsock API Interception code (http://webpagetest.googlecode.com/svn/trunk/

Agent/wpthook/hook_winsock.cc)

• Code injection (http://webpagetest.googlecode.com/svn/trunk/agent/wpthook/inject

. CC)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.