品味性能之道<八>: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/ ...
随机推荐
- PyQt
知识内容: 1. 2. 3. 以后有时间再写...
- C_point指针
1,关于C语言中变量的访问方式,直接访问[使用变量名直接引用,操作变量进行赋值,改变变量值等操作],间接访问--指针,一种指向变量飞, 程序对变如量的读写操作,实际是对变量所在的存储空间进行写入和取出 ...
- (13/24) css进阶:自动处理css3属性前缀
什么是属性前缀 为了浏览器的兼容性,有时候我们必须加入-webkit,-ms,-o,-moz这些前缀.目的就是让我们写的页面在每个浏览器中都可以顺利运行. 例如: transition: width ...
- c# 导入导出excel表格式
c#使用代码导入excel时,当遇到纯数字且大于15位时会出现编码混乱(表现为科学计数法),要想呈现与excel表中纯数字格式和在数据库中呈现纯数字,操作如下: 完成即可. 导出取决于导入的内容排版.
- hive xml udf
<store> <book id="book"><title id="titile">hive</title> ...
- TestNG中DataProvider的用法
提供数据的一个测试方法.注解的方法必须返回一个Object[] [],其中每个对象 []的测试方法的参数列表中可以分配.该@Test 方法,希望从这个 DataProvider 的接收数据,需要使用一 ...
- Delphi 解析HTML
uses mshtml; IHTMLEleMent.ID; IHTMLEleMent.tagName; IHTMLEleMent.title;elmt._className;elmt.getAttri ...
- jquery ajax 赋值问题, 后面程序判断逻辑用
添加async:false; 像 $.get() 等是没有async参数的, 所以需要用到如下 $.ajaxSetup({ async : false //这个意思是等这个ajax有了返回值后才会执行 ...
- as2 fla 关于影片在时间轴的问题
多帧上面放着没实例名而且里面内容一致的影片,主要一开始读取了,那么跳帧的时候.会自动获取当前帧上的相同内容的影片. 但如果内容不一致的影片,那么在跳帧后,不会获取当前的影片,旧的影片也无法获取.只在当 ...
- UI5-文档-2.4-Node.js-Based开发环境
用于修改OpenUI5.环境是基于Node.js,用作服务器,具有一个基于Grunt的构建过程.本节提供关于初始设置.开发工作流和测试执行的信息. 常规开发过程: 不需要构建过程,您可以简单地修改任何 ...



