我们正在评估如何在 single-page application (SPA) 上测试性能这在很大程度上依赖于 JavaScript 和动态内容(通过 Ajax 更新)。
流行的负载测试工具,如 Apache JMeter或 Gatling能够通过发送 HTTP 请求用很少的硬件产生巨大的负载。但它们不处理任何 Javascript 代码。
我们想衡量客户端感知的性能,即坐在浏览器前的最终用户感知的性能(包括所有渲染和 JavaScript 开销)。
我们考虑了以下备选方案:
使用 Selenium Grid 在多台机器上同时运行测试脚本。每个实例都将在运行时收集的延迟数据提交到中央存储库。
与上面类似,只是只启动了一个 Selenium 脚本实例。然后,我们将使用 JMeter/Gatling 在后台生成重负载。
根本不要使用 Selenium。使用 JMeter/Gatling 运行负载测试时,使用 Firebug、YSlow 等工具手动检查页面的行为。
每种方法都有其优点和缺点。在 (1) 上,我能够创建最“真实”的负载,但它无法缩放,(2) 通过 JMeter/Gatling 缩放,但我必须确保它们创建的负载不会与实际应用程序偏离太多,(3) 是最容易设置的,但显然很耗时,因为它不是自动化的。
到目前为止,我找不到关于这个主题的任何工具、框架,甚至一套指南,所以我想从 SO 的专家那里了解:他们使用什么样的方法进行此类测试?
This entry on the Selenium Grid FAQ声明*“使用真实浏览器进行性能/负载测试是一个非常糟糕的主意,因为扩展负载很难/昂贵并且实际负载非常不一致......”。我只能认为他们指的是“后端性能/负载测试”。否则,如果我对最终用户性能感兴趣,还有什么选择?
最佳答案
查看 JMeter WebDriver http://jmeter-plugins.org/wiki/WebDriverTutorial/ .您可以定义一个并行负载测试,以衡量服务器在负载下时客户端感知的性能。
来自他们的网站:
Web Driver Sampler automates the execution and collection of Performance metrics on the Browser (client-side). A large part of performance testing, up to this point, has been on the server side of things. However, with the advancement of technology, HTML5, JS and CSS improvements, more and more logic and behaviour have been pushed down to the client. This adds to the overall perceived performance of website/webapp, but this metric is not available in JMeter. Things that add to the overall browser execution time may include:
Client-side Javascript execution - eg. AJAX, JS templates CSS transforms - eg. 3D matrix transforms, animations 3rd party plugins - eg. Facebook like, Double click ads, site analytics, etc All these things add to the overall browser execution time, and this project aims to measure the time it takes to complete rendering all this content.
关于javascript - 如何在单页(Web)应用程序上进行 "end-client"性能测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21780391/