如何在jmeter中使用变量如计数器 [英] how to use variable in jmeter like counter

查看:764
本文介绍了如何在jmeter中使用变量如计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jmeter脚本中使用了循环控制器,但无法在预处理器beanshell中获取先前的变量值.

I'm using loop controller inside the jmeter script, and I'm not able to fetch previous variable value in pre-processor beanshell.

示例:

var temp = 1; log.info("before : "+temp.toString()); temp++; prev.put("t",temp.toString());

预先感谢

推荐答案

要保存值的黑白迭代:

以下是存储和检索黑白迭代值的方法之一:

Following is one of the ways to store and retrieve the values b/w iterations:

log.info("temp prev value " + vars.get("temp")); // first iteration returns null
vars.put("temp","something"); // store or override the value, so it will be available in next iterations.

要了解迭代编号:

如果您需要知道迭代编号,请使用Counter:

If your need is to know the iteration number, then use Counter:

在beanshell预处理器中,使用引用名称(计数器)进行访问,如下所示:

In beanshell preprocessor, access using reference name (counter) as shown below:

这篇关于如何在jmeter中使用变量如计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆