JMeter 如何在打开另一个页面时测试页面加载性能

JMeter How to test page loading performance while another page is open

我想知道是否有一种方法可以在 jmeter 中测试以下场景:

站点:一个站点有2个页面,其中一个(我们称之为heavy-page),加载完成后,消耗大量系统资源(cpu),另一个没有(我们称之为 light-page)。

  1. 模拟1000个用户(线程)加载并停留在重载页面
  2. 当这 1000 名用户仍在重载页面时,让另一组 1000 名用户加载轻载页面。

关键问题是,如何让第一组线程模拟用户在加载完成后停留在页面上,同时让另一组用户加载轻量级页面?

目前我有这样的东西:

Group1 (1000 threads, loop count 1):
 - Runtime controller (set to 5min, so each thread runs for 5 minutes):
   - heavy-page
Group2: (1000 threads, loop count 1, and a startup delay set to 2 minutes, so it starts after all threads in Group1 are running)
 - light-page

这几乎完成了所有我想要的,除了我看到重页面发送的请求比我预期的多得多(超过 1000),就像它没有识别 G1 中设置为 1 的循环计数。我不确定这背后的原因是否是因为 sampler/thread 在运行时控制器内,它只是在控制器设置的时间内永远循环,这意味着(我认为)用户不仅仅是在页面停留5分钟,但是在页面加载完后一个接一个发送请求,这不是我要测试的

  1. 在您的设置中,用户不会“停留”在“重要页面”,而是 re-opening 一次又一次。运行时控制器不考虑循环计数,它会在指定的持续时间内运行其子项。

  2. 根据JMeter Project main page:

    JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).

  3. JMeter 的HTTP Request samplers don't "stay" at the page, they execute request, retrieve the response, measure time taken and if there are no more samplers to execute and loops to iterate the thread is being shut down. If there are background events happening at the "heavy" page like AJAX requests or WebSocket requests you need to simulate them using Parallel Controller or WebSocket Samplers