当前位置:网站首页>BeanShell built-in variable CTX
BeanShell built-in variable CTX
2022-07-24 05:17:00 【Agricultural garden】
1 brief introduction
It can easily access the context of the current thread
stay JMeter Inside ,ctx It maps to org.apache.jmeter.threads Of JMeterContext class because JMeterContext
No thread safety , Therefore, it is only applicable to use in single thread
Official documents :https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html
2 Common methods
2.1 getVariables
Method statement
public JMeterVariables getVariables()
function : obtain JMeter All variables of the current thread
vars.put("name","shenzhen");
shen = ctx.getVariables().get("name");
log.info("name value is "+ shen);
result :
2.2 getProperties
Method statement
public Properties getProperties()
function : Get all JMeter attribute
sh = ctx.getProperties().getProperty("sampleresult.default.encoding");
log.info("sampleresult.default.encoding value is "+sh);
result :
2.3 getPreviousResult
Method statement
public SampleResult getPreviousResult()
function : Get the results of the previous sampler
import org.apache.jmeter.samplers.SampleResult
SampleResult rsp= ctx.getPreviousResult();
String sh= rsp.getResponseDataAsString();
log.info("\n"+sh);

result :
2.4 getCurrentSampler
Method statement
public Sampler getCurrentSampler()
function : Get the current sampler object
shs =ctx.getCurrentSampler().getName();
log.info("csn value is "+shs);
result :
2.5 getPreviousSampler
Method statement
public Sampler getPreviousSampler()
function : Get the previous sampler object
shs =ctx.getPreviousSampler().getName();
log.info("csn value is "+shs);
result :
2.6 getThreadNum
Method statement
public int getThreadNum()
function : Get the thread number under the current thread group ( Number from 0 Start )
2.7 getThread
Method statement
public JMeterThread getThread()
function : Get thread object
shs =ctx.getThreadNum();
log.info("csn value is "+shs);
shsname =ctx.getThread().getThreadName();
log.info("shsname is "+shsname);
result :
2.8 getThreadGroup
Method statement
public AbstractThreadGroup getThreadGroup()
function : Get thread group object
shs =ctx.getThreadGroup().getName();
log.info("csn value is "+shs);

边栏推荐
- Read "effective managers - Drucker"
- C#表格数据去重
- ssm的整合
- 【NumPy】
- Source code compilation!!
- Smart pointer, lvalue reference, lvalue reference, lambda expression
- DNS domain name resolution service
- [Huang ah code] Introduction to MySQL - 3. I use select *, and the boss directly rushed me home by train, but I still bought a station ticket
- Pointer learning diary (II)
- Introduction to MapReduce
猜你喜欢

The world's first large aerospace model came out. Wenxin's second supplement "Fuchun Mountain Residence map" is Baidu Pratt Whitney AI's perseverance

Read "effective managers - Drucker"

Fiddler抓包工具的使用

Chapter 1 regression, classification & clustering

DHCP principle and configuration

Learning pyramid context encoder network for high quality image painting paper notes

浅谈不可转让的声誉积分NFT SBTs面临的困境

Kingbase v8r6 cluster installation and deployment case - script online one click expansion

Teach you how to weld CAD design board bottom (for beginners) graphic tutorial

Kingbase v8r6 cluster installation and deployment case - script online one click capacity reduction
随机推荐
NFS shared services
[Basic 6] - encapsulation and inheritance of classes, objects and classes
It is related to the amount of work and ho. Embedded, only one 70 should be connected
Kingbase v8r6 cluster installation and deployment case - script online one click expansion
Jiang Xingqun, senior vice president of BOE: aiot technology enables enterprise IOT transformation
How can NFT, whose stars enter the market against the market, get out of the independent market?
Pointer learning diary (I)
招聘| 嵌入式軟件(单片机)工程师
How to set up an internal wiki for your enterprise?
DHCP principle and configuration
Mrs +apache Zeppelin makes data analysis more convenient
generator生成器,只生成两个方法
Icml2022 | rock: causal reasoning principle on common sense causality
1. Input a 100 point score from the keyboard and output its grade according to the following principles: score ≥ 90, Grade A; 80 ≤ score < 90, grade B; 70 ≤ score < 80, grade C; 60 ≤ score < 70, grade
[postgraduate entrance examination vocabulary training camp] day 10 - capital, expand, force, adapt, depand
[basic 8] - processes and threads
ssm的整合
The difference between statement and Preparedstatement and how to use placeholders
。单类型数字传感一个应用程.0。 Up- 开址在出厂
Kingbase V8R6集群安装部署案例---脚本在线一键扩容