品味性能之道<八>:Loadrunner关联技巧与字符处理
一、概述
Loadrunner作为HP出品的性能测试工具,拥有太多奇妙魔法甜点供予性能测试人员享用,其中吃起来比较有嚼劲的那就是关联了。当然在关联之后我们还需要一些简单的字符处理,用以生成我们所需要的切糕、煎饼果子等。
Session在 网络应用中称为“会话”,借助它可提供客户端与服务系统之 间必要的交互。因为HTTP协议本身是无状态的,所以经常需要 通过Session来解决服务端和浏览器的保持状态的解决方案。用户 向服务器发送第一个请求时,服务器为其建立一个Session,并为 此Session创建一个标识,用户随后的所有请求都应包括这个标识 号。服务器会校对这个标识号以判断请求属于哪个Session。会话 保持有效,默认状况下,直到浏览器关闭,会话才结束。
Session中存储的内容包括用户信息:昵称、用户ID、登录状 态等。
我们的服务器通过SESSIONID确认了,谁是谁?但是在我们所录制的脚本里面,每次发送的协议包还一直是我们所录制的内容,此时就引发了如下报错信息:
Error -26612: HTTP Status-Code=500 (Internal Server Error) for
- 数据新增修改删除,违反唯一索引(未关联页面隐藏的表关键字段)
- 发送回服务器的字段所用字符集,不能被服务器正确解析
- SESSIONID不被服务器认可
- 开启浏览器F12开发人员工具,分析页面request与response
- 如果还是难以发现其中症结,就从svn下载源码,自己搭建开发环境,回放脚本发送协议,源码中断点排查
- 当没有源码的情况下,我们还可以考虑反编译war文件,利用Eclipse及其强大的插件,断点排查

(1)、明确关联字段

<r id="value":这里的“value”作为服务器确认字段唯一操作ID,它是我们需要关联的字段。

在确定我们的主键为PARTY_ID之后,我们通过查询数据库得知,前五位为”10000“,长度为十四的数字为我们需要关联的另一个字段。(因涉及安全原因数据库查询结果,不能予以展示)
web_reg_save_param_ex(
"ParamName=ridList",
"LB= r id=\"",
"RB= \"",
"Ordinal=ALL",
SEARCH_FILTERS,
"Scope=All",
"RequestUrl=**********************", LAST);
创建关于主键字段的关联,相对比较复杂。在此确定它的左边界为:,1000,右边界为:,1。关联函数如下如下:
web_reg_save_param_ex(
"ParamName=party_id",
"LB=,1000",
"RB=,1",
"Ordinal=ALL",
SEARCH_FILTERS,
"Scope=All",
"RequestUrl=**********************",LAST);
lr_eval_string("{ridList_1}");
在此推荐一个LR提供随机获取数组元素的函数:
lr_paramarr_random("ridList");
总所周知Loadrunner是以c语言为基础设计的脚本,我们常常需要对关联函数所生成的字符进行一些简单的操作,在此分享一些c语言字符操作函数及语法知识。
| 函数名 | 英文描述 | 乌龙翻译(看不明白,就别看了) |
| strset |
Fills a string with a specific character.
char *strset( char *string1, int character );
string1 The string to which to add the characher. character The character(s) to add.
|
一二三四五,来一起变身,凸凸凸凸凸 |
| strchr |
Returns the pointer to the first occurrence of a character in a string.
char *strchr( const char *string, int c );
string The string that is searched.
c The character that is searched for in the string.
|
买猪肉,从第一块脊骨那儿斩断,只要后面的,多了不要 |
| strrchr |
Finds the last occurrence of a character in a string.
char *strrchr( const char *string, int c );
string The string that is searched.
c The character that is searched for in the string.
|
又买猪肉,从最后一块脊骨那儿斩断,只买后面的
胃口不好,少吃点,话说最后一块脊骨后面,是啥呢?
|
| strcpy |
Copies one string to another.
char *strcpy( char *dest, const char *source );
dest The destination string into which source is copied.
source The string that is sopied.
|
克隆其实很简单,复制一个字符串到另一个字符串中 |
| strncpy |
Copies the first n characters of one string to another.
char *strncpy( char *dest, const char *source, size_t n );
dest The destination string to which n characters are copied. source The source string from which n characters are copied.
n The number of characters copied.
|
买了一头猪,看中了大前蹄前面一节儿,切好了装我兜里,包括大前蹄哟 |
| strdup |
Duplicates a string.
char *strdup( const char *string );
string The string that is duplicated.
|
复制一个字符串 |
| strlen |
Returns the length of a string.
size_t strlen( const char *string );
string The string whose is returned.
|
“鞭长莫及” |
| strwr |
Converts a string to lower case.
char *strlwr( char *string );
string The string whose characters are converted to lower case.
|
好吧,中文可没小写版,别乱用哟 |
|
strupr
|
Converts a string to upper case.
char *strupr( char *string );
string The string whose characters are converted to upper case.
|
好吧,中文可没大写版,别乱用哟 |
| strcmp |
Compares two strings to determine the alphabetic order.
int strcmp( const char *string1, const char *string2 );
string1 The frist string that is compared.
string2 The second string that is compared.
|
大小写敏感
|
| stricmp |
Performs a case-insensitive comparison of two strings.
int stricmp( const char *string1, const char *string2 );
string1 The firest string for comparison.
string2 The second string for comparison.
|
大小写不敏感
|
| strncmp |
Compares the first n characters of two strings.
int strncmp( const char *string1, const char *string2, size_t n );
string1 The firest string for comparison.
string2 The second string for comparison.
n The number of characters in each string that are compared.
|
大小写敏感
|
|
strnicmp
|
Performs a case-insensitive comparison of n strings.
int strnicmp( const char *string1, const char *string2, size_t num);
string1 The firest string for comparison.
string2 The second string for comparison.
num The number of characters to compare.
|
大小写不敏感
|
| strcat |
Concatenates two strings.
char *strcat( char *to, const char *from );
to The string at the end of which the from string is concatenated. from The string concatenated to the end of the to string.
|
String"B"接到String"2"后面,化生String"2B"
|
| strncat | Concatenates n characters from one string to another.
char *strncat( char *to_string, const char *from_string, size_t n );
to_string The string to which n charachters are concatenated.
from_string The string from whice n charachters are concatenated.
n The number of characters to be concatenated.
|
String"BBBB"接到String"2"后面,只接一位,化生String"2B" |
| strstr |
Returns the first occurrence of one string in another.
char *strstr( const char *string1, const char *string2 );
string1 The string that is searched. string2 The string that is searched for in the first string.
|
查找一个字符串 |
| strtok |
Returns a token from a string delimited by specified characters.
char *strtok( char *string, const char *delimiters );
string The string to scan. delimiters The string consisting of the character or characters that delimit tokens in the first string.
|
老板,来一整根龙骨,按每个骨节切开,依着原来的顺序打包给我 |
| strspn |
Returns the length of the leading characters in a string that are contained in a specified string.
size_t *strspn( const char *string, const char *skipset ); string Null -terminated string to be scanned.
skipset Null -terminated string containing character set.
|
strspn返回string起始部分匹配skipset 中任意字符串的字符数 |
以上代码相关内容不感兴趣的同学,其实可以跳过滴。
//argv为源字符串,delimiters为切分分隔符,number为所需获取分隔符数
char* strlick(char *argv,const char delimiters ,int number)
{
int i;
int j = ;
int p = ;
char buf[] = {};
if(number < )
{
return "the number can't < 1";
}
for(i = ;argv[i] != ;i++)
{
buf[j] = argv[i];
if(argv[i] == delimiters)
{
buf[j] = ;
if(p == number) return buf;
j = ;
p++;
continue;
}
j++;
}
return "can't find";
}
//argv为源字符串,delimiters为切分分隔符, number为所需获取分隔符数 ,length为所需截取字符长度
char* strputty(char *argv,const char delimiters ,int number,int length)
{
int count = ;
char buf[] = {};
int i ;
for(i = ;argv[i] != ;i++)
{
if(argv[i] == delimiters)
{
if(count == number)
{
strncpy(buf,argv + i +,length);
return buf;
}
count++;
continue;
}
}
return "can't find";
}
(4)、替换关联字段
品味性能之道<八>:Loadrunner关联技巧与字符处理的更多相关文章
- 品味性能之道<九>:利用Loadrunner编写socket性能测试脚本简述
一.概述 Loadrunner拥有极为丰富的工具箱,供予我们制造出各种奇妙魔法的能力.其中就有此次要讨论的socket套接字操作. 二.socket概述 ...
- 品味性能之道<十一>:JAVA中switch和if性能比较
通常而言大家普遍的认知里switch case的效率高于if else.根据我的理解而言switch的查找类似于二叉树,if则是线性查找.按照此逻辑推理对于对比条件数目大于3时switch更优,并且对 ...
- 品味性能之道<十>:Oracle Hint
Hint 是Oracle 提供的一种SQL语法,它允许用户在SQL语句中插入相关的语法,从而影响SQL的执行方式. 因为Hint的特殊作用,所以对于开发人员不应该在代码中使用它,Hint 更像是Ora ...
- 品味性能之道<七>:索引基础
一.索引概述 索引(index),它是数据库必不可少的一部分.它其实很简单呐!很好理解. 索引好比如一本书的目录,一张地图,一个写字楼里挂在大堂墙上的公司名录,一个地铁站的出口指示 ...
- 品味性能之道<六>:图形化SQL分析工具
在上一章里,重点分享了命令行SQL分析工具的使用方法.在本章将重点分享PL/SQL的SQL分析工具. 一.如何打开PL/SQL执行计划 开启PL/SQL这工具,推荐如下方法: 点击 ...
- 品味性能之道<五>:SQL分析工具
一.SQL语句到底是怎么执行的? 想了解SQL语句到底是怎么执行的,那就需要进行SQL语句执行计划分析. 那什么是SQL语句执行计划呢? 就是Oracle服务器执行SQL语句的过程.例如确定是否使用索 ...
- 品味性能之道<三>:方法论
自顶向下的性能优化方法论 系统优化是包括系统设计.开发.产品上线.平台优化的全过程,不同阶段的优化工作对全系统所带来的效益是不同的.理想的性能优化论应该采用自顶向下的优化方法,即在项目设计.开发和上线 ...
- 品味性能之道<四>:管理重于技术
一.性能优化中的角色分工 (1).老外的角色分工 在oracle性能优化方法论中,将IT系统中不同角色需要承担的性能优化工作罗列如下. 各司其职的角色分工 业务分析人员 1.业务需 ...
- 品味性能之道<二>:性能工程师可以具备的专业素养
性能工程师可以具备的专业素养 程序语言原理,包括:C.C++.java及jvm.ASP,因为建站大部分外围应用和中间件都是JAVA编写,大部分的电商平台采用的ASP编写,底层核心系统是C/ ...
随机推荐
- 安全svn快速安装
按照如下步骤快速搭建centos6下的svn系统并支持https协议checkout和import代码,亲测成功! 1.[基本包yum安装] yum httpd subversion mod_dav_ ...
- Xshell使用
xshell更新之后窗口标题没了,多个窗口之后没法切换. 使用ctrl+shift+t恢复 ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
- 36. CentOS-6.3安装Mysql集群
安装要求 安装环境:CentOS-6.3安装方式:源码编译安装 软件名称:mysql-cluster-gpl-7.2.6-linux2.6-x86_64.tar.gz下载地址:http://mysql ...
- 高负载均衡学习haproxy之安装与配置
https://www.cnblogs.com/ilanni/p/4750081.html
- SpringBoot 常用注解(持续更新)
SpringBoot 常用注解 @SpringBootApplication @Bean @ComponentScan @ControllerAdvice @ExceptionHandler @Res ...
- heat 用法 示例
heat.exe dir "./SampleFolder" -cg Files -dr INSTALLDIR -gg -g1 -sf -srd -var "var.Tar ...
- sql查询分析器中显示行号
-- 工具-> -- 选项-> -- 文本编辑器-> -- 所有语言-> -- 常规-> -- 显示-> -- 行号
- 正则表达式(Java,C#,C++)
课题 使用正则表达式匹配字符串 使用正则表达式 "\d{3}-(\d{4})-\d{2}" 匹配字符串 "123-4567-89" 返回匹配结果:'" ...
- 吴裕雄 数据挖掘与分析案例实战(13)——GBDT模型的应用
# 导入第三方包import pandas as pdimport matplotlib.pyplot as plt # 读入数据default = pd.read_excel(r'F:\\pytho ...
- express + mongodb 搭建一个简易网站(二)
express + mongodb 搭建一个简易网站 (二) 在搭建网站(一)中,实现了简单的路由功能,这离一个完整的网站还差的有点远,继续撸代码吧. 1.首先在根目录下新建一个views文件夹,用来 ...



