我已经设置了一个JMeter脚本:
For a number of pages of information
1) Loads 1 page of information
2) Parses out a set of elements to be looked up from that page
3) Queries each of the parsed elements
问题是上面的(3)是串行的,而我需要它是并行的。有没有办法做到这一点或更好的例子?
我的测试计划大纲:
Thread group
+ Loop Controller (load more than 1 page of information)
Counter (Controls the start of my page loading)
+ HTTP Request (Loads the page of information)
Regular Expression Extractor (To get my elements)
+ ForEach Controller (Varies over my extracted elements)
HTTP Request (My retrieved elements)
ForEach控制器/和最后一个HTTP请求是我需要并行的,这是我正在模拟的浏览器中的行为
由于
答案 0 :(得分:0)
假设您的正则表达式提取器参考名称为PARAM
,您应该得到类似的内容:
PARAM_1=some value
PARAM_2=some other value
PARAM_matchNr=2
为了实现并发性,您需要删除您的ForEach控制器并按如下方式实施计划:
Thread group
+ Loop Controller (load more than 1 page of information)
Counter (Controls the start of my page loading)
+ HTTP Request (Loads the page of information)
Regular Expression Extractor (To get my elements)
+ HTTP Request (My retrieved elements)
Synchronizing Timer
相关配置:
在需要引用{PARAM_1}
等的HTTP请求(我的检索到的元素)中,输入以下代码:
${__V(PARAM_${__threadNum})}
__threadNum -s JMeter函数返回当前线程的编号,因此第一个线程的动态参数为$ {PARAM_1},第二个线程为$ {PARAM_2}等。
Synchronizing Timer暂停线程执行,除非满足指定数量的线程。我希望您希望线程数等于正则表达式匹配数。为此,请将以下内容放入“要分组的模拟用户数”输入中:
${PARAM_matchNr}
请记住,您需要在线程组中提供足够的(等于匹配数量或更多)线程,否则您的测试将无限悬挂。
希望这会有所帮助。