WebPagetest网页前端性能测试工具和实现分析

本文涉及的产品
性能测试 PTS,5000VUM额度
简介: WebPageTest 原本是由AOL开发内部使用的工具,后来在Google Code上开源, 是一款非常优秀的网页前端性能测试工具。 在线版本http://www.webpagetest.orgGoogle Code: http://code.

WebPageTest 原本是由AOL开发内部使用的工具,后来在Google Code上开源, 是一款非常优秀的网页前端性能测试工具。 在线版本http://www.webpagetest.org

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

部署WebPageTest 私有实例参考资料

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

http://testing.etao.com/node 

如下是作者提供的客户端实现分析  

the networking stack on Windows from a browser’s perspective

wps_clip_image-28040

Function Interception

The key to how WebPagetest works is its ability to intercept arbitrary function calls

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 the

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 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 calls to code running in the same process as the

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 to…

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 but

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 essentially lets

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

the necessary rights).

Resulting Browser Architecture

wps_clip_image-8319

Get the Code

Since WebPagetest is under a BSD license you are welcome to reuse any of the code for

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)

相关实践学习
通过性能测试PTS对云服务器ECS进行规格选择与性能压测
本文为您介绍如何利用性能测试PTS对云服务器ECS进行规格选择与性能压测。
相关文章
|
4月前
|
数据采集 监控 机器人
浅谈网页端IM技术及相关测试方法实践(包括WebSocket性能测试)
最开始转转的客服系统体系如IM、工单以及机器人等都是使用第三方的产品。但第三方产品对于转转的业务,以及客服的效率等都产生了诸多限制,所以我们决定自研替换第三方系统。下面主要分享一下网页端IM技术及相关测试方法,我们先从了解IM系统和WebSocket开始。
93 4
|
4月前
|
前端开发 JavaScript API
(前端3D模型开发)网页三维CAD中加载和保存STEP模型
本文介绍了如何使用`mxcad3d`库在网页上实现STEP格式三维模型的导入与导出。首先,通过官方教程搭建基本项目环境,了解核心对象如MxCAD3DObject、Mx3dDbDocument等的使用方法。接着,编写了加载和保存STEP模型的具体代码,包括HTML界面设计和TypeScript逻辑实现。最后,通过运行项目验证功能,展示了从模型加载到保存的全过程。此外,`mxcad3d`还支持多种其他格式的三维模型文件操作。
|
17天前
|
人工智能 自然语言处理 前端开发
DeepSite:基于DeepSeek的开源AI前端开发神器,一键生成游戏/网页代码
DeepSite是基于DeepSeek-V3模型的在线开发工具,无需配置环境即可通过自然语言描述快速生成游戏、网页和应用代码,并支持实时预览效果,显著降低开发门槛。
246 36
DeepSite:基于DeepSeek的开源AI前端开发神器,一键生成游戏/网页代码
|
5月前
|
前端开发 JavaScript 测试技术
前端测试技术中,如何提高集成测试的效率?
前端测试技术中,如何提高集成测试的效率?
|
2月前
|
JSON 前端开发 测试技术
大前端之前端开发接口测试工具postman的使用方法-简单get接口请求测试的使用方法-简单教学一看就会-以实际例子来说明-优雅草卓伊凡
大前端之前端开发接口测试工具postman的使用方法-简单get接口请求测试的使用方法-简单教学一看就会-以实际例子来说明-优雅草卓伊凡
128 10
大前端之前端开发接口测试工具postman的使用方法-简单get接口请求测试的使用方法-简单教学一看就会-以实际例子来说明-优雅草卓伊凡
|
2月前
|
JSON 前端开发 API
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
96 5
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
|
3月前
|
机器学习/深度学习 人工智能 自然语言处理
MarS:微软开源金融市场模拟预测引擎,支持策略测试、风险管理和市场分析
MarS 是微软亚洲研究院推出的金融市场模拟预测引擎,基于生成型基础模型 LMM,支持无风险环境下的交易策略测试、风险管理和市场分析。
135 8
MarS:微软开源金融市场模拟预测引擎,支持策略测试、风险管理和市场分析
|
3月前
|
人工智能 前端开发 架构师
2025年前端局势分析,我该不该转行?
2024年,前端领域经历了快速变化,AIGC的兴起和市场HC减少使得前端工程师面临挑战。尽管AI工具如通义灵码和Cursor能高效生成代码,但AI无法完全取代前端工程师,因其缺乏逻辑、沟通和创新能力。前端工作不仅限于编码,还包括需求分析、代码评审等。未来,前端不会“死亡”,而是持续演变。面对大环境的压力,提升综合能力、拥抱变化、持续学习和保持身心健康是关键。转型方向包括升管理、做架构师或转讲师等。稳住2025年,需适应变化、不断学习并探索更多可能性。
476 16
|
4月前
|
开发框架 .NET Java
C#集合数据去重的5种方式及其性能对比测试分析
C#集合数据去重的5种方式及其性能对比测试分析
57 11
|
4月前
|
开发框架 .NET Java
C#集合数据去重的5种方式及其性能对比测试分析
C#集合数据去重的5种方式及其性能对比测试分析
74 10

热门文章

最新文章