jmeter添加自定义扩展函数之DoubleSum
1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这里就不再赘述
2,代码如下:
package com.mytest.functions;
import org.apache.jmeter.engine.util.CompoundVariable; import org.apache.jmeter.functions.AbstractFunction; import org.apache.jmeter.functions.InvalidVariableException; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.samplers.Sampler; import org.apache.jmeter.threads.JMeterVariables; import java.util.Collection; import java.util.LinkedList; import java.util.List; /** * Provides a DoubleSum function that adds two or more Double values. * Mostly copied from LongSum */ public class DoubleSum extends AbstractFunction { private static final List<String> desc = new LinkedList<String>(); private static final String KEY = "__doubleSum"; static { desc.add("First double to add"); desc.add("Second long to add - further doubles can be summed by adding further arguments"); desc.add("Name of variable in which to store the result (optional),The author is guanyf"); } private Object[] values; /** * No-arg constructor. */ public DoubleSum() { } /** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); Double sum = 0D; String varName = ((CompoundVariable) values[values.length - 1]).execute().trim(); for (int i = 0; i < values.length - 1; i++) { sum += Double.parseDouble(((CompoundVariable) values[i]).execute()); } try { sum += Double.parseDouble(varName); varName = null; // there is no variable name } catch (NumberFormatException ignored) { } String totalString = Double.toString(sum); if (vars != null && varName != null && varName.length() > 0) {// vars will be null on TestPlan vars.put(varName, totalString); } return totalString; } /** * {@inheritDoc} */ @Override public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkMinParameterCount(parameters, 2); values = parameters.toArray(); } /** * {@inheritDoc} */ @Override public String getReferenceKey() { return KEY; } /** * {@inheritDoc} */ @Override public List<String> getArgumentDesc() { return desc; } }
jmeter添加自定义扩展函数之DoubleSum的更多相关文章
- jmeter添加自定义扩展函数之图片base64编码
打开eclipse,新建maven工程,在pom中引入jmeter核心jar包: <!-- https://mvnrepository.com/artifact/org.apache.jmete ...
- jmeter添加自定义扩展函数之if判断
1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...
- jmeter添加自定义扩展函数之小写转换大写
1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...
- jmeter添加自定义扩展函数之大写转换小写
1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...
- jmeter添加自定义扩展函数之MD5加密
1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...
- jmeter添加自定义扩展函数之Strng---base64解密
1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...
- jmeter添加自定义扩展函数之String---base64加密
1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...
- jmeter添加自定义扩展函数之图片base64
原文连接:---------https://www.cnblogs.com/qiaoyeye/p/7218770.html----------- 打开eclipse,新建maven工程,在pom中引用 ...
- jmeter的使用--添加自定义函数和导入自定义jar
1.添加自定义函数,增加 号码生成函数 MobileGenerator和身份证生成函数IdCardGenerator 在package org.apache.jmeter.functions;中增加 ...
随机推荐
- [Linux] 003 分区
1. 磁盘分区 使用分区编辑器再磁盘上划分几个逻辑部分 不用类的目录与文件可以存储进不同的分区 2. 分区类型 主分区 最多只能有 4 个 扩展分区 最多只能有 1 个 主分区加扩展分区最多为 4 个 ...
- mysql 5.7 创建函数报错,This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creat
今天用命令创建函数, 报错 This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration ...
- [暑假集训Day4T1]羊圈
ZYC同志开农场了????? 二分答案. 对于每一个二分出来的答案对其进行检查(check),检查是否有一个长度大于m的字段和的平均值大于mid.方法如下:先把原数组的每一个元素减去mid,储存进一个 ...
- Codeforces Round #535 E2-Array and Segments (Hard version)
Codeforces Round #535 E2-Array and Segments (Hard version) 题意: 给你一个数列和一些区间,让你选择一些区间(选择的区间中的数都减一), 求最 ...
- hive Hsql
show databases; use flume; show tables; desc flume; alter table table_name add columns(dt string); a ...
- Linux之systemd服务配置及自动重启
layout: post title: Linux之systemd服务配置及自动重启 date: 2019-09-09 tags: linux --- Linux之systemd服务配置及自动重启 0 ...
- JVM(5)之 GC之标记
开发十年,就只剩下这套架构体系了! >>> 堆分为年轻代和年老代.永久代是非堆内存,它又叫做方法区(一般的说法),主要存储已被加载的类信息.常量.静态变量.而该区域在java ...
- 高级定时器-setTimeout()、setInterval()、链式setTimeout()
使用 setTimeout()和 setInterval()创建的定时器可以用于实现有趣且有用的功能.执行时机是不能保证的,因为在页面的生命周期中,不同时间可能有其他代码在控制 JavaScript ...
- lvm相关
LVM 概念:PV(单个硬件)--VG(组合)--LV(分区) pv打头的:代表pv相关的命令vg带头的:代表vg相关的命令lv带头的: 代表lv相关的命令 create:创建相关remove:移除相 ...
- Vue:列表渲染 v-for on a <template>
类似于 v-if,你也可以利用带有 v-for 的 <template> 渲染多个元素.比如: <html> <head> <title>Vue v-f ...