<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PerformanceCompetence.com</title>
	<atom:link href="http://www.performancecompetence.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.performancecompetence.com/wordpress</link>
	<description>by Chaitanya Bhatt</description>
	<lastBuildDate>Mon, 10 Oct 2011 08:25:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>LoadRunner: A thread-safe duplicate file creator function which also automatically assigns unique names to files</title>
		<link>http://www.performancecompetence.com/wordpress/2011/10/10/test/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/10/10/test/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 06:53:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=402</guid>
		<description><![CDATA[Note: 1.Make sure you copy the upload file into your script folder by right clicking on the action pane and pressing the &#8220;Add files to script&#8221; option 2.Adding a file to script makes sure that your file automatically gets copied to the LoadGenerators during load test execution. 3.After the load test completes &#8211; ensure to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong><br />
1.Make sure you copy the upload file into your script folder by right clicking on the action pane and pressing the &#8220;Add files to script&#8221; option<br />
2.Adding a file to script makes sure that your file automatically gets copied to the LoadGenerators during load test execution.<br />
3.After the load test completes &#8211; ensure to cleanup your %TEMP% folders as several duplicate files may be created during test execution.<br />
4.I have used randAlphaNumrGenerator.h which hosts a helper function to create random alphanumeric codes which can be used as names for duplicate files.<br />
5.I have  also used strLastOccr() function which I explained in my previous post. In the current context I have used it to extract the extension of the file.<br />
6.In the below example I have added dataFile.xlsx into my script folder using the &#8220;Add files to script&#8221; option. This is the file I intend to duplicate during execution.</p>
<p>Function call sample:</p>
<pre class="brush: php; title: ; notranslate">
	char fileName[20]=&quot;dataFile.xlsx&quot;;
	fileDuplication(fileName);
	return 0;
</pre>
<p>Global Declaration:</p>
<pre class="brush: php; title: ; notranslate">
#ifndef _GLOBALS_H
#define _GLOBALS_H

//--------------------------------------------------------------------
// Include Files
#include &quot;lrun.h&quot;
#include &quot;web_api.h&quot;
#include &quot;lrw_custom_body.h&quot;
#include &quot;randAlphaNumrGenerator.h&quot;
#define DIR_LEN 512
#define BUFFER_SIZE 10240 // 10 KB

//--------------------------------------------------------------------
// Global Variables

#endif // _GLOBALS_H
</pre>
<p><strong>The duplicate file creator function</strong></p>
<pre class="brush: php; title: ; notranslate">

int fileDuplication(char *fileToDuplicate)
{

	long fp, count;
	int id, scid;
	char filename[1024];
	char cmdPWD[1024];
	char cmdCopy[2024] ;
	char buffer[BUFFER_SIZE];
	char original_dir[DIR_LEN];
	char *vuser_group;

	lr_output_message(&quot;Actual Filename with Extension = \&quot;%s\&quot;&quot;,
					  fileToDuplicate);

	strLastOccr(fileToDuplicate, &quot;fileExtension&quot;, &quot;.&quot;);

	lr_output_message(&quot;File Extension= %s&quot;,
					  lr_eval_string(&quot;{fileExtension}&quot;));

	lr_whoami(&amp;id, &amp;vuser_group, &amp;scid);

	alphNumGen(&quot;randFilename&quot;);

	 lr_output_message(&quot;%s&quot;,getcwd (original_dir, DIR_LEN));
	 sprintf(cmdPWD, &quot;cd %s&quot;, original_dir);
	 lr_output_message(&quot;%s&quot;,cmdPWD); //Present Working Directory
	 system(cmdPWD);
	 sprintf(cmdCopy, &quot;copy %s.%s %s.%s&quot;,fileToDuplicate,lr_eval_string(&quot;{fileExtension}&quot;), lr_eval_string(&quot;{randFilename}&quot;), lr_eval_string(&quot;{fileExtension}&quot;));
	 lr_output_message(&quot;cmdCopy = %s&quot;, cmdCopy);

	 fp = popen(cmdCopy, &quot;r&quot;);
		if (fp == NULL) {
			lr_error_message(&quot;Error opening stream.&quot;);
			return -1;
		}

		count = fread(buffer, sizeof(char), BUFFER_SIZE, fp); // read up to 10KB
		if (feof(fp) == 0) {
			lr_error_message(&quot;Couldn't reach end of stream. Try increasing BUFFER_SIZE.&quot;);
			return -1;
		}
		if (ferror(fp)) {
			lr_error_message (&quot;Error during read operation.&quot;);
			return -1;
		}
		buffer[count] = NULL;

		lr_output_message(&quot;Copy Status for Vuser-%d is %s. FileName=%s.%s&quot;, id, buffer,lr_eval_string(&quot;{randFilename}&quot;),lr_eval_string(&quot;{fileExtension}&quot;));

		pclose(fp);

		return 0;
}
</pre>
<p>Output:</p>
<pre class="brush: php; title: ; notranslate">
Running Vuser...
Starting iteration 1.
Starting action Action.
globals.h(61): Actual Filename with Extension = &quot;dataFile.xlsx&quot;
globals.h(66): File Extension= xlsx
Max: 1
globals.h(74): Z:\temp\FUS\noname68
globals.h(76): cd Z:\temp\FUS\noname68
globals.h(79): cmdCopy = copy dataFile.xlsx n25579.xlsx
globals.h(99): Copy Status for Vuser--1 is         1 file(s) copied.
. FileName=n25579.xlsx
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
globals.h(61): Actual Filename with Extension = &quot;dataFile.xlsx&quot;
globals.h(66): File Extension= xlsx
Max: 1
globals.h(74): Z:\temp\FUS\noname68
globals.h(76): cd Z:\temp\FUS\noname68
globals.h(79): cmdCopy = copy dataFile.xlsx X25459.xlsx
globals.h(99): Copy Status for Vuser--1 is         1 file(s) copied.
. FileName=X25459.xlsx
Ending action Action.
Ending iteration 2.
Ending Vuser...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/10/10/test/feed/</wfw:commentRss>
		<slash:comments>362</slash:comments>
		</item>
		<item>
		<title>LoadRunner: A C function to fetch a portion of the string after locating the last occurance of a delimiter</title>
		<link>http://www.performancecompetence.com/wordpress/2011/08/29/loadrunner-a-c-function-to-fetch-a-string-portion-based-on-last-occurance-of-a-delimiter/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/08/29/loadrunner-a-c-function-to-fetch-a-string-portion-based-on-last-occurance-of-a-delimiter/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 18:58:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=387</guid>
		<description><![CDATA[A very handy function when you are processing URLs and/or HTTP response. Function call Action() { //example URL lr_save_string("https://mail.google.com/mail/?hl=en&#038;tab=wm#inbox", "InputName"); lr_output_message("String before processing = \"%s\"", lr_eval_string("{InputName}")); strLastOccr(lr_eval_string("{InputName}"), "OutputProjName", "/"); lr_output_message("Portion of the string after last occurance of forward-slash= %s", lr_eval_string("{OutputProjName}")); return 0; } Function description void strLastOccr(char inputStr[100], char* outputStr, char *delim) { char value[100],*temp, [...]]]></description>
			<content:encoded><![CDATA[<p>A very handy function when you are processing URLs and/or HTTP response.</p>
<p>Function call</p>
<pre><code>
Action()
{
//example URL
lr_save_string("https://mail.google.com/mail/?hl=en&#038;tab=wm#inbox", "InputName");

lr_output_message("String before processing = \"%s\"",
				  lr_eval_string("{InputName}"));

strLastOccr(lr_eval_string("{InputName}"), "OutputProjName", "/");

lr_output_message("Portion of the string after last occurance of forward-slash= %s",
				  lr_eval_string("{OutputProjName}"));
return 0;
}
</pre>
<p><code><br />
Function description</p>
<pre><code>
void strLastOccr(char inputStr[100], char* outputStr, char *delim)
{

	char value[100],*temp, *temp2;
	int i = 0;

	temp = "";
	while (temp!=NULL)
	{

		if(i==0)
		{
			temp2 = temp;
			temp = (char *)strtok(inputStr,delim);
			i++;

		}

		if(i>0)
		{
			temp2 = temp;
			temp = (char *)strtok(NULL,delim);

		}

		lr_save_string(temp2,outputStr);

	}
}
</pre>
<p><code><br />
Output</p>
<pre><code>
Starting iteration 1.
Starting action Action.
Action.c(7): String before processing = "https://mail.google.com/mail/?hl=en&#038;tab=wm#inbox"
Action.c(13): Portion of the string after last occurance of forward-slash= "?hl=en&#038;tab=wm#inbox"
Ending action Action.
Ending iteration 1.</pre>
<p><code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/08/29/loadrunner-a-c-function-to-fetch-a-string-portion-based-on-last-occurance-of-a-delimiter/feed/</wfw:commentRss>
		<slash:comments>1409</slash:comments>
		</item>
		<item>
		<title>LoadRunner: Explicitly Dealing with HTTP Redirect Requests</title>
		<link>http://www.performancecompetence.com/wordpress/2011/08/26/loadrunner-dealing-with-http-redirect-requests/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/08/26/loadrunner-dealing-with-http-redirect-requests/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 19:55:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=344</guid>
		<description><![CDATA[By default, LoadRunner does not show Redirect requests in the script, though it take care of redirects during replay. This becomes an issue during transaction analysis, because all redirect requests and corresonding responses are combined into one step and shows up as one transaction in the results report. The web_url/web_custom_request/web_submit_data functions automatically detects a 302 [...]]]></description>
			<content:encoded><![CDATA[<p>
By default, LoadRunner does not show Redirect requests in the script, though it take care of redirects during replay. This becomes  an issue during transaction analysis, because all redirect requests and corresonding responses are combined into one step and shows up as one transaction in the results report. </p>
<p>The web_url/web_custom_request/web_submit_data functions automatically detects a 302 response from the server and redirects to the location specified in the response header. </p>
<p>The problem with automatic redirection in LoadRunner is that you will NOT be able to figure out the amount of time it takes for each redirected request. Redirects are invisible to the user in LoadRunner. But in few test requirements you would want to know the break up of response timings between primary hit and the redirected server hits. The bigger problem comes in when you are dealing with recursive redirects.</p>
<p>To make an explicit redirect request you will first have to turn off automatic following of redirect instructions. This can be accomplished by setting MaxRedirectionDepth to &#8217;0&#8242;. The key thing to remember is to identify redirected location by analyzing &#8220;Location: http://<YourNewDistinationURL>&#8221; line item in the HTTP response header of the request in question. </p>
<p>Example:</p>
<p><pre><code>//In your action file
Place this in the beginning of the action file

web_set_option("MaxRedirectionDepth", "0", LAST ); //This is the key

recursiveRedirect_open();
web_url("url_which_gets_redirected","http://sampleredirect.com/",LAST);
recursiveRedirect_close();
</code></pre>
</p>
<p>Here is how you do it:</p>
<pre><code>//place this in global.h

int HttpRetCode;
int i=0;
char depthVal[10];
char cTransactName[20000];

recursiveRedirect_open()
{
	web_set_max_html_param_len("10000");

	web_reg_save_param("cRedirectUrl",
			    "LB=Location: ",
			    "RB=\r\n",
			    "notfound=warning",
			    "Search=Headers",
			    LAST);

	web_reg_save_param("cTransactionName",
			    "LB=https://Domain.com/",
			    "RB=\r\n",
			    "Search=Headers",
			    "notfound=warning",
			    LAST);

	web_reg_save_param("httpCode",
			    "LB=HTTP/1.1 ",
			    "RB= ",
			    "Search=Headers",
			    "ORD=1",
			    "notfound=warning",
			    LAST);
}

recursiveRedirect_close()
{

	HttpRetCode = atoi(lr_eval_string("{httpCode}"));
	lr_output_message("xReturnCode=%d",  HttpRetCode);

	if(HttpRetCode == 302)//If redirect
	{
		i++;
		web_reg_save_param("cRedirectUrl",
			    "LB=Location: ",
			    "RB=\r\n",
			    "Search=Headers",
			    "notfound=warning",
			    LAST);

		web_reg_save_param("cTransactionName",
			    "LB=https://https://Domain.com/",
			    "RB=\r\n",
			    "Search=Headers",
			    "notfound=warning",
			    LAST);

		web_reg_save_param("httpCode",
			   "LB=HTTP/1.1 ",
			   "RB= ",
			   "ORD=1",
			   "notfound=warning",
			   LAST);

sprintf(cTransactName, "Redirect_depth_%d_%s", i,lr_eval_string("{cTransactionName}"));
lr_start_transaction(cTransactName);
web_url(cTransactName, "URL={cRedirectUrl}", "Mode=HTTP", LAST);
lr_end_transaction(cTransactName, LR_AUTO);
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
recursiveRedirect_close();

}
else
{
	return;
}

}</code></pre>
</p>
<p>The above code automatically generates new transactions for each unique follow redirect request&#8217;s made by the script. It keeps a track of the HTTP response code of each request and exits from recursion state when the response code is not 302. </p>
<p>The first challenge is to find the requests in the script which has URL redirections. If you find it hard to identify the locations where redirects are performed in the script, run the script after including web_set_option(&#8220;MaxRedirectionDepth&#8221;, &#8220;0&#8243;, LAST );  with standard log enabled. After the script completes executing, check the logs for &#8220;redirection depth exceeded&#8221; message, because whenever a web server prompts for a redirection of the resource, it sends back a 302 HTTP code with the new location, but since MaxRedirectionDepth is set to 0 in LoadRunner it will not explicitly hit the new URL. This is where the above script comes into play. Now, double click on that line, and Vugen will highlight the step where the redirection was attempted. Now place the recursiveRedirect_open() and recursiveRedirect_close() function call at the start and end of the concerned step/request and you should be good to go!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/08/26/loadrunner-dealing-with-http-redirect-requests/feed/</wfw:commentRss>
		<slash:comments>2044</slash:comments>
		</item>
		<item>
		<title>LoadRunner: A C function to convert a floating number to string</title>
		<link>http://www.performancecompetence.com/wordpress/2011/07/19/loadrunner-a-c-function-to-convert-a-floating-number-to-string/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/07/19/loadrunner-a-c-function-to-convert-a-floating-number-to-string/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 18:22:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=318</guid>
		<description><![CDATA[I would like to call this function as ftoa here is the code&#8230; Note: To adjust the radix/floating point position...you will have to further customize this function. ftoa(float floatNum, char *convFloatString) {  char new[10];  float number,dTemp,temp_val;  int base, floatVal, radxFlag;  char *token;  char *temp;  char cfloatVal[10], cBase[10];  char cfloatValx[10] = "0";    int DEBUG = [...]]]></description>
			<content:encoded><![CDATA[<p>I would like to call this function as <strong>ftoa</strong></p>
<p>here is the code&#8230;</p>
<pre><code>Note: To adjust the radix/floating point position...you will have to further customize this function.
</code></pre>
<pre>ftoa(float floatNum, char *convFloatString)
{

 char new[10];
 float number,dTemp,temp_val;
 int base, floatVal, radxFlag;
 char *token;
 char *temp;
 char cfloatVal[10], cBase[10];
 char cfloatValx[10] = "0";
 
 int DEBUG = 1; //Turn DEBUG OFF/ON by switch 0/1

 radxFlag = 0;

 //Separate the number before and after the "."
 number = floatNum;
 base=number;
 dTemp = number-base;

 if(DEBUG == 1)
 {
   lr_output_message("Base Value = %f\n", number);
 }

 sprintf(cBase, "%d", base);

 if(DEBUG == 1)
 {
  lr_output_message("Floating Value = %.2f\n", dTemp);
 }

 if(dTemp == 0) //If number is a whole number then return!
 {
  lr_save_string(cBase, convFloatString);
  return 0;
 }

 sprintf(cfloatVal, "%.2f", dTemp); //Place the decimal point to suit your requirement. Default is 2

 temp = (char *)strtok(cfloatVal, "0.");

 temp_val = atoi(temp);

 if((dTemp - 0.1) &lt; 0)
  radxFlag=1; 
 else
  radxFlag=0;

 if(temp_val == 0)//If decimal values equals to 0 then return!
 {
  strcat(cfloatVal, ".00"); //increase the number of zero to suit your requirement.
  lr_save_string(cfloatVal, convFloatString);
  return;
 }

 if (radxFlag ==1)
 {
  strcat(cfloatValx,temp);
  strcpy(temp,cfloatValx);
 }

 if(DEBUG == 1)
 {
  lr_output_message("Final decimal value  = %s\n", temp);
 }

 
 if(strlen(temp) == 1 &amp;&amp; radxFlag == 0)
 {
  strcat(temp,cfloatValx);
  //strcpy(temp,cfloatValx);
  if(DEBUG == 1)
  {
   lr_output_message("Appending a 0 %s", temp);

  }

 }

 strcat(cBase, ".");
 strcat(cBase, temp);

 if(DEBUG == 1)
 {
  lr_output_message("Final decimal value  = %s\n", cfloatVal);
 }

 if(DEBUG == 1)
 {
  lr_output_message("Final coverted floating number = %s", cBase);
 }

 lr_save_string(cBase, convFloatString);

}</pre>
<pre> Sample usage:</pre>
<pre> float floatNum;

 floatNum = 34.102;
 
 ftoa(floatNum, "convFloatStr");

 lr_output_message("Converted String = %s", lr_eval_string("{convFloatStr}"));

 return 0;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/07/19/loadrunner-a-c-function-to-convert-a-floating-number-to-string/feed/</wfw:commentRss>
		<slash:comments>2034</slash:comments>
		</item>
		<item>
		<title>LoadRunner: A C function to find substring using left and right boundaries</title>
		<link>http://www.performancecompetence.com/wordpress/2011/06/28/loadrunner-a-c-function-to-find-substring-using-left-and-right-boundary-strings/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/06/28/loadrunner-a-c-function-to-find-substring-using-left-and-right-boundary-strings/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 01:36:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=300</guid>
		<description><![CDATA[This kind of works like the popular LoadRunenr web_reg_save_param function, hence I named it as web_reg_param_custom() void web_reg_save_param_custom(char *sourceStr, char* outpuStr, char *leftBdry, char *rightBdry) { char *st1, *st2; int result, i = 0; i=strlen(leftBdry); st1 = (char*) strstr(sourceStr, leftBdry); if (st1 != NULL){ st1 += i; st2 = (char*) strstr(st1, rightBdry); if (st2 != [...]]]></description>
			<content:encoded><![CDATA[<p>This kind of works like the popular LoadRunenr web_reg_save_param function, hence I named it as web_reg_param_custom()</p>
<pre><code>void web_reg_save_param_custom(char *sourceStr, char* outpuStr, char *leftBdry, char *rightBdry)

{
	char *st1, *st2;
	int result, i = 0;

             i=strlen(leftBdry);
	st1 = (char*) strstr(sourceStr, leftBdry);

	if (st1 != NULL){
		st1 += i;
		st2 = (char*) strstr(st1, rightBdry);

		if (st2 != NULL){
			result = st2 - st1;
			*(st1 + result) = '\0';
		}
	}

	if ((st1 == NULL) || (st2 == NULL))
		lr_error_message("Error: No substring found for the specified boundary");
             else
    	             lr_save_string(lr_eval_string(st1), outpuStr);

}</code></pre>
<p>Usage example:</p>
<pre><code>web_reg_save_param_custom(lr_eval_string("{originalString}"),"outputString","token", "endKey" );</code></pre>
<p>The function call shown above fetches a substring from the &#8220;originalString&#8221; parameter and saves it in &#8220;outputString&#8221; paramater based on the Left and Right boundary values &#8211; &#8220;Token&#8221; and &#8220;endKey&#8221;. So if &#8220;originalString&#8221; param had the value &#8220;xyzToken3234344endKey,&#8221; the outputString parameter will contain the value &#8220;3234344&#8243;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/06/28/loadrunner-a-c-function-to-find-substring-using-left-and-right-boundary-strings/feed/</wfw:commentRss>
		<slash:comments>1972</slash:comments>
		</item>
		<item>
		<title>LoadRunner: Creating dll files and using it in LR scripts</title>
		<link>http://www.performancecompetence.com/wordpress/2011/06/22/loadrunner-creating-dll-files-and-using-in-lr-scripts/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/06/22/loadrunner-creating-dll-files-and-using-in-lr-scripts/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 22:37:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=280</guid>
		<description><![CDATA[Creating DLLs have tons of advantage, especially when you want to take your scripts away from the beaten path. I won&#8217;t blabber much in this post and would like to take you people right into the topic I want to cover. In the previous post I mentioned about Search And Replace function. To serve the [...]]]></description>
			<content:encoded><![CDATA[<p>Creating DLLs have tons of advantage, especially when you want to take your scripts away from the beaten path.  I won&#8217;t blabber much in this post and would like to take you people right into the topic I want to cover. </p>
<p>In the previous post I mentioned about Search And Replace function. To serve the purpose of an example, I have recreated the same Search And Replace function in VC++(2010) expresss edition and built a DLL file.</p>
<p>Below is the code that I created in VC++</p>
<pre><code>#include "stdafx.h"
#include "C:\Program Files\HP\LoadRunner\include\lrun.h"

extern "C" __declspec( dllexport ) int lr_searchReplace(char* inputStr, char* outputStr, char lookupChar, char repChar);

int lr_searchReplace(char* inputStr, char* outputStr, char lookupChar, char repChar)
	{

    	char *ptr =inputStr;
		char xchar;
		int len=0;
		int i=0;

		lr_output_message("%s",inputStr);
		xchar = *ptr;//Copy initial
		len=strlen(inputStr);
		while (len&gt;0)
		{

			len--;
			xchar = *ptr;
			if(xchar==' ')
			{
				inputStr[i]= repChar;

			}

			ptr++;
			i++;

		}

	  lr_save_string(inputStr,outputStr);
      lr_output_message("%s",inputStr);

	  return 0;
	}
</code></pre>
<p>Before attempting to build this dll project in VC++, ensure that you have included lrun50.lib in the aditional linker file settings which is in Project Options, else the project won&#8217;t successfully build/compile. lrun.lib should be present inside <LR Installation Directory>\lib folder. Also make sure you include the lrun.h header file as shown in the above code snippet. </p>
<p>After the project is built, dig into the debug folder to find the dll file and then copy it inside the LoadRunner script folder and use it as shown below:</p>
<pre><code>Action()
{
   lr_load_dll("SearchNReplace.dll");
   lr_save_string("this is a dummy text", "cProjectName");
   r_searchReplace(lr_eval_string("{cProjectName}"), "convProjName", ' ', '+');
   lr_output_message("%s",lr_eval_string("{convProjName}"));
   return 0;
}</code></pre>
<p>Download Link for Sample URL = <a href='http://www.performancecompetence.com/wordpress/wp-content/uploads/2011/06/SearchNReplace.zip'>SearchNReplace</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/06/22/loadrunner-creating-dll-files-and-using-in-lr-scripts/feed/</wfw:commentRss>
		<slash:comments>1731</slash:comments>
		</item>
		<item>
		<title>LoadRunner: C string function for search and replace</title>
		<link>http://www.performancecompetence.com/wordpress/2011/06/21/loadrunner-c-string-function-for-search-and-replace/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/06/21/loadrunner-c-string-function-for-search-and-replace/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 18:11:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=265</guid>
		<description><![CDATA[Example of function call: lr_save_string(&#8220;chaitanya m bhatt&#8221;, &#8220;InputName&#8221;); lr_searchReplace(lr_eval_string(&#8220;{InputName}&#8221;), &#8220;OutputProjName&#8221;, &#8216; &#8216;, &#8216;+&#8217;); Note: Space &#8211; &#8216; &#8216; is the input character or lookup character and &#8216;+&#8217; is the character which will be replaced in the place of the lookup character. Note that the input string is = &#8220;chaitanya m bhatt&#8221; . In this name [...]]]></description>
			<content:encoded><![CDATA[<p>Example of function call:<br />
lr_save_string(&#8220;chaitanya m bhatt&#8221;, &#8220;InputName&#8221;);<br />
lr_searchReplace(lr_eval_string(&#8220;{InputName}&#8221;), &#8220;OutputProjName&#8221;, &#8216; &#8216;, &#8216;+&#8217;);</p>
<p>Note: Space &#8211; &#8216; &#8216; is the input character or lookup character and &#8216;+&#8217; is the character which will be replaced in the place of the lookup character.</p>
<p>Note that the input string is = &#8220;chaitanya m bhatt&#8221; . In this name the lookup character is space &#8211; &#8216; &#8216;.<br />
The expected output string is = &#8220;chaitanya+m+bhatt&#8221; since the variable repChar is set to &#8216;+&#8217;.</p>
<pre><code>
void lr_searchReplace(char* inputStr, char* outputStr, char lookupChar, char repChar)
	{

    		char *ptr =inputStr;
		char xchar;
		int len=0;
		int i=0;

		lr_output_message("%s",inputStr);
		xchar = *ptr;//Copy initial
		len=strlen(inputStr);
		while (len&gt;0)
		{

			len--;
			xchar = *ptr;
			if(xchar==lookupChar)
			{
				inputStr[i]= repChar;

			}

			ptr++;
			i++;

		}

	  lr_save_string(inputStr,outputStr);
               lr_output_message("%s",inputStr);

	}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/06/21/loadrunner-c-string-function-for-search-and-replace/feed/</wfw:commentRss>
		<slash:comments>1439</slash:comments>
		</item>
		<item>
		<title>Fun Script: A simple single level Web Crawler using LoadRunner</title>
		<link>http://www.performancecompetence.com/wordpress/2011/01/14/fun-script-a-simple-single-level-web-crawler-using-loadrunner/</link>
		<comments>http://www.performancecompetence.com/wordpress/2011/01/14/fun-script-a-simple-single-level-web-crawler-using-loadrunner/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 10:52:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=248</guid>
		<description><![CDATA[Author: Chaitanya M Bhatt //Try it out! /*Change the URL in seeder function to the desired parent URL from where you wish to start crawling.*/ char newlinkup[100]; int i; web_reg_save_param("newlink", "LB=href="", "RB="", "ORD=All", LAST); web_reg_find("Text=href=", "SaveCount=xCount", LAST); web_url("Seeder Function", "URL=http://www.google.com/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Snapshot=t1.inf", "Mode=HTML", LAST); for(i=2; atoi(lr_eval_string("{xCount}")); i++) { sprintf(newlinkup, "{newlink_%d}", i); lr_save_string(lr_eval_string(newlinkup), "newlinkstring"); [...]]]></description>
			<content:encoded><![CDATA[<pre><code>Author: Chaitanya M Bhatt
//Try it out!
/*Change the URL in seeder function to the desired parent URL from where  you wish to start crawling.*/

char newlinkup[100];
int i;

web_reg_save_param("newlink", "LB=href="", "RB="", "ORD=All", LAST);

web_reg_find("Text=href=", "SaveCount=xCount", LAST);

web_url("Seeder Function",
"URL=http://www.google.com/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Snapshot=t1.inf",
"Mode=HTML",
LAST); 

for(i=2; atoi(lr_eval_string("{xCount}")); i++)
{

sprintf(newlinkup, "{newlink_%d}", i);
lr_save_string(lr_eval_string(newlinkup), "newlinkstring");

 web_url("Crawler Function" target="_blank"&gt;</a>",
 "URL={newlinkstring}",
 "TargetFrame=",
 "Resource=0",
 "RecContentType=text/html",
 "Snapshot=t1.inf",
 "Mode=HTML",
 LAST);

}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2011/01/14/fun-script-a-simple-single-level-web-crawler-using-loadrunner/feed/</wfw:commentRss>
		<slash:comments>1547</slash:comments>
		</item>
		<item>
		<title>Software Load Test Scripting: Best Practices</title>
		<link>http://www.performancecompetence.com/wordpress/2010/11/02/220/</link>
		<comments>http://www.performancecompetence.com/wordpress/2010/11/02/220/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 17:38:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/2010/11/02/220/</guid>
		<description><![CDATA[1.0 Plan your Business Process scripting effort Successful performance testing relies on in-depth understanding of the application, the business requirements of the customer and careful planning of the script development phase. 1.1  Gather relevant data Make sure you get the document that describes the business objectives of the application, maps the customer environment and provides [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.performancecompetence.com/ChaitanyaMBhatt_BestPractic_PerformanceCompetence.GIF" alt="" /></p>
<h3><strong>1.0 Plan your Business Process scripting effort</strong></h3>
<p>Successful performance testing relies on in-depth understanding of the application, the business requirements of the customer and careful planning of the script development phase.</p>
<p><strong>1.1  Gather relevant data</strong><br />
Make sure you get the document that describes the business objectives of the application, maps the customer environment and provides the most appropriate solution at each stage of deployment. This document provides the foundation for the scripting effort and must be created before the script planning and development by the business analysts/Solution Architects.</p>
<ul>
<li> Understand the organization’s goals</li>
<li> Identify the key IT-enabled business processes to achieve these goals</li>
<li> Meet the stakeholders</li>
<li> Identify pain points and current state of environment</li>
<li> Map and analyze the tested applications</li>
<li> Define the project deliverables and objectives</li>
<li> Plan the test environment</li>
<li> For further details refer to the Performance Testing Product Best Practices document.</li>
</ul>
<p><strong> 1.2 Map the application</strong><br />
Get familiar with the application you’re about to test. Understanding the real user workflows that map together and form a business process is the most important step to creating the script design.   With a thorough script design, the emulation of real user interaction is legitimate, traceable, and logical.  Technical errors are more easily discovered through good test design, and logical errors do not become an issue. Additionally such step might be helpful to detect certain actions that may need special attention (e.g. a web page that often returns an error in a web based application). Interview the system administrator and the application developers (if available) and learn how the application works and its internal architecture. Focus on gathering the following data for each application:</p>
<ul>
<li> How the applications is being used by its regular users</li>
<li> Application architecture (2/3 tier client/server, ASP/Java, etc)</li>
<li> The internal process of the application and how they work</li>
<li> Protocols used (HTTP, JavaScript/JSP, Tuxedo/JOLT, etc)</li>
<li> Development Source: Vendor or in-house, or combination?</li>
<li> Communication paths to the application (WAN/LAN, link speed, known congestion issues)</li>
<li> Security issues (firewalls, username/passwords etc.)</li>
<li> Data required to interact with the application.</li>
</ul>
<p><strong> 1.3 Create the Performance Testing requirements document</strong><br />
The Performance Testing Requirements document is the cornerstone of any Performance Testing project. It must include precise definitions of what would be achieved during the project implementation and set the Performance Testing strategy. Within the Performance Testing Requirements document should reside Use Case scenarios that define the business processes necessary to emulate the load.  Thus, this document becomes the basis for the script design, and should contain the following aspects:</p>
<ul>
<li>Business processes that need to be tested.</li>
<li>The flow of each business process.</li>
<li>Key Performance Indicators (KPI)s per business process.  KPIs map what the expected results of the script execution should indicate.  For example, a KPI for a script that emulates a login-logout business process would be the number of seconds that is appropriate for the transaction to be considered acceptable.</li>
</ul>
<p>Make sure you get the stakeholders approval for the test plan before moving forward.</p>
<p><strong>1.4 Plan the Performance Testing </strong><br />
Performance testing in a pre-production environment should be the final step before deploying applications into production. One of the significant contributors to the high cost of application testing is duplication of script development efforts.  In order to reduce such inefficiencies, the planning phase should begin weeks before the actual script development and can be performed during other functional testing efforts. In this stage create the detailed Performance testing plan. The plan should cover the following aspects of performance testing:</p>
<ul>
<li>Decide which functions should be tested.  These functions represent the business processes of real users interacting with the system under test</li>
<li>Identify the required Performance test types/Performance test cases.</li>
<li>Align the application lifecycle with the available tests. Make sure that the performance tests you have chosen are suitable for the application lifecycle (development, pre-production or production).</li>
<li>Define in detail the performance test scenarios.</li>
</ul>
<p><strong>1.5 Validate the test environment</strong></p>
<p style="padding-left: 30px;"><strong>1.5.1 Align with the production environment</strong><br />
It is important to run Performance tests against an environment that is as similar as possible to the production environment; otherwise this could lead to inaccurate test results.<br />
The performance test environment requires at least two sets of testing environments:</p>
<ul>
<li> Production infrastructure</li>
<li> Test environment</li>
</ul>
<p style="padding-left: 30px;"><strong>Note: </strong>Normally most of the performance testing would be done in the test environment; however there are situations where the business requirement would be to run certain performance tests on the production environment to validate its readiness for the next business day.</p>
<p style="padding-left: 30px;"><strong>1.5.2 Decide what to script </strong><br />
Analyze the Use Case scenarios and understand the impact they have on the system under test.  Oftentimes, several Use Case scenarios have the same effect when executed, making the scripting of them redundant.  Therefore, it is efficient to identify these redundancies and decide to script only a small subset of the larger set of business processes.  For example, the “login” use case and the “logout” use case both impact the same middleware code and the same database tables, so it may not be necessary to script both processes and execute them.</p>
<p style="padding-left: 30px;">There are three criteria for deciding what to script: <strong> </strong></p>
<ul>
<li><strong>Volume</strong>:  the most common business processes that generate the highest total number of interaction.</li>
<li><strong>Dynamic Content</strong>:  The business processes that cause the most workload for the system, especially workload that involves dynamic information to be produced.</li>
<li><strong>Mission Critical</strong>:  Not necessarily those business processes which fulfill the above two requirements, but are use cases that are considered the most important aspects of the application usage.</li>
</ul>
<p style="padding-left: 30px;">
<blockquote><p>Normally you will find that the Pareto 80-20 rule applies in such situations: 20 percent of the transactions cause 80 percent of the system load. Identifying those 20 percent in the script design phase (and deciding they are the most relevant to your script) ensures that every performance test accurately mimics the load generated by users.</p></blockquote>
<p><strong>1.6  Scripting design document</strong></p>
<p>Prepare a script design document which explains the Use Case Scenarios and fulfills the framework of the overall Performance Test Plan.</p>
<ul>
<li>The script design document should contain, at minimum, the following details:</li>
<li> The Business Process name (and the technical script name that represents its emulation).</li>
<li> The Performance Test to which the script is being executed for.</li>
<li> The specific transactions within the script that are being measured for performance (the script may itself be measured, as well as individual steps within it).</li>
<li> The KPIs that will contrast the results of the transactions against expectations.</li>
<li> Technical issues (such as protocol considerations, network considerations, etc).</li>
<li> Environmental configuration (mapped to the Run-Time Settings of the Performance test scenario).</li>
<li> Data considerations.</li>
</ul>
<table style="width: 430px; height: 52px;" border="0">
<tbody>
<tr>
<td>Business process</td>
<td>Script main purpose</td>
<td>Script technical name</td>
</tr>
<tr>
<td>Search Friends in Facebook</td>
<td>Web transaction: Login, Search Friends, Logout.</td>
<td>Facebook_SearchFriends_01</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1229px; width: 1px; height: 1px; padding-left: 90px;">
<p><img src="http://www.performancecompetence.com/ChaitanyaMBhatt_BestPractic_PerformanceCompetence.GIF" alt="" /></p>
<h3><strong>1.0 Plan your Business Process scripting effort</strong></h3>
<p>Successful performance testing relies on in-depth understanding of the application, the business requirements of the customer and careful planning of the script development phase.</p>
<p><strong>1.1  Gather relevant data</strong><br />
Make sure you get the document that describes the business objectives of the application, maps the customer environment and provides the most appropriate solution at each stage of deployment. This document provides the foundation for the scripting effort and must be created before the script planning and development by the business analysts/Solution Architects.<br />
Understand the organization’s goals<br />
Identify the key IT-enabled business processes to achieve these goals<br />
Identify the target Performance Center users’ Organization Structure (from strategic business champions to technical experts).<br />
Meet the stakeholders<br />
Identify pain points and current state of environment<br />
Map and analyze the tested applications<br />
Define the project deliverables and objectives<br />
Plan the test environment<br />
For further details refer to the Performance Testing Product Best Practices document.</p>
<p>4.1.1    Map the application<br />
Get familiar with the application you’re about to test. Understanding the real user workflows that map together and form a business process is the most important step to creating the script design.   With a thorough script design, the emulation of real user interaction is legitimate, traceable, and logical.  Technical errors are more easily discovered through good test design, and logical errors do not become an issue. Additionally such step might be helpful to detect certain actions that may need special attention (e.g. a web page that often returns an error in a web based application). Interview the system administrator and the application developers (if available) and learn how the application works and its internal architecture. Focus on gathering the following data for each application:<br />
How the applications is being used by its regular users<br />
Application architecture (2/3 tier client/server, ASP/Java, etc)<br />
The internal process of the application and how they work<br />
Protocols used (HTTP, JavaScript/JSP, Tuxedo/JOLT, etc)<br />
Development Source: Vendor or in-house, or combination?<br />
Communication paths to the application (WAN/LAN, link speed, known congestion issues)<br />
Security issues (firewalls, username/passwords etc.)<br />
Data required to interact with the application.</p>
<p>4.2    Create the Performance Testing requirements document<br />
The Performance Testing Requirements document is the cornerstone of any Performance Testing project. It must include precise definitions of what would be achieved during the project implementation and set the Performance Testing strategy. Within the Performance Testing Requirements document should reside Use Case scenarios that define the business processes necessary to emulate the load.  Thus, this document becomes the basis for the script design, and should contain the following aspects:<br />
Business processes that need to be tested.<br />
The flow of each business process.<br />
Key Performance Indicators (KPI)s per business process.  KPIs map what the expected results of the script execution should indicate.  For example, a KPI for a script that emulates a login-logout business process would be the number of seconds that is appropriate for the transaction to be considered acceptable.<br />
Make sure you get the stakeholders approval for the test plan before moving forward. For further details refer to the Performance Testing Product Best Practices document.<br />
4.3    Plan the Performance Testing<br />
Performance testing in a pre-production environment should be the final step before deploying applications into production. One of the significant contributors to the high cost of application testing is duplication of script development efforts.  In order to reduce such inefficiencies, the planning phase should begin weeks before the actual script development and can be performed during other functional testing efforts. In this stage create the detailed Performance testing plan. The plan should cover the following aspects of performance testing:<br />
Decide which functions should be tested.  These functions represent the business processes of real users interacting with the system under test<br />
Identify the required Performance test types. Refer to the Performance Testing Product Best Practices document for a list of commonly used performance test types and choose the ones that make sense in your business environment.<br />
Align the application lifecycle with the available tests. Make sure that the performance tests you have chosen are suitable for the application lifecycle (development, pre-production or production). Refer to the Performance Testing Product Best Practices document for recommended test types per the application lifecycle.<br />
Define in detail the performance test scenarios.<br />
For further details refer to the Performance Testing Product Best Practices document.<br />
4.4    Validate the test environment<br />
4.4.1    Align with the production environment<br />
It is important to run Performance tests against an environment that is as similar as possible to the production environment; otherwise this could lead to inaccurate test results.<br />
The performance test environment requires at least two sets of testing environments:<br />
Production infrastructure<br />
Test environment</p>
<p>Note: Normally most of the performance testing would be done in the test environment; however there are situations where the business requirement would be to run certain performance tests on the production environment to validate its readiness for the next business day.<br />
For further details refer to the Performance Testing Product Best Practices document.</p>
<p>4.4.2    Decide what to script<br />
Analyze the Use Case scenarios and understand the impact they have on the system under test.  Oftentimes, several Use Case scenarios have the same effect when executed, making the scripting of them redundant.  Therefore, it is efficient to identify these redundancies and decide to script only a small subset of the larger set of business processes.  For example, the “login” use case and the “logout” use case both impact the same middleware code and the same database tables, so it may not be necessary to script both processes and execute them.  There are three criteria for deciding what to script:<br />
Volume:  the most common business processes that generate the highest total number of interaction.<br />
Dynamic Content:  The business processes that cause the most workload for the system, especially workload that involves dynamic information to be produced.<br />
Mission Critical:  Not necessarily those business processes which fulfill the above two requirements, but are use cases that are considered the most important aspects of the application usage.<br />
Normally you will find that the Pareto 80-20 rule applies in such situations: 20 percent of the transactions cause 80 percent of the system load. Identifying those 20 percent in the script design phase (and deciding they are the most relevant to your script) ensures that every performance test accurately mimics the load generated by users.</p>
<p>4.5    Scripting design document<br />
Prepare a script design document which explains the Use Case Scenarios and fulfills the framework of the overall Performance Test Plan.  The script design document should contain, at minimum, the following details:<br />
The Business Process name (and the technical script name that represents its emulation).<br />
The Performance Test to which the script is being executed for.<br />
The specific transactions within the script that are being measured for performance (the script may itself be measured, as well as individual steps within it).<br />
The KPIs that will contrast the results of the transactions against expectations.<br />
Technical issues (such as protocol considerations, network considerations, etc).<br />
Environmental configuration (mapped to the Run-Time Settings of the Performance test scenario).<br />
Data considerations</p>
<p>4.5.1    The Business Process and the technical script name<br />
As in any serious development effort keep the program/script names as meaningful as possible. Such approach allows fast identification of relevant scripts and better code re-use. Use the following sample name conventions:</p>
<p>Business process    Script main purpose    Script technical name<br />
Search the portal content    Web transaction: Login, search, log-out    portalSearch_01_1<br />
Customer records update    SAP GUI transaction – update customer records    SAP_custom_rec_02_03</p>
<p>The first part of the script name contains the script protocol and the main transaction that would be performed while the next part has the script revision number (for simple version control).</p>
<p>4.5.2    The Performance Test<br />
Each script should be mapped to the relevant performance test as described in the Performance Testing requirements document. Identify per each performance test the applicable scripts and write it down in the Script design document.<br />
4.5.3    The specific transactions that would be measured<br />
Document the business transactions and their workflow for each script. For better granularity and future code re-use plan to have purpose focused scripts that do a limited number of transactions. Another benefit of such approach is that in case of a problem, it would be easier to identify where the script failed and what area of the application needs fine tuning.<br />
4.5.4    KPIs<br />
Write down the KPIs that would be tested and their expected values per each script such as the expected response time of the GUI during the various transactions.<br />
4.5.5    Technical issues (if applicable)<br />
Document any known technical issues such as protocol-related issues that need to be addressed or avoided during the script development phase.<br />
4.5.6    Environmental configuration<br />
Specify environmental configuration mapped to the Run-Time Settings of the Performance test scenario that would be utilized during the execution of scripts. Mention any special or non-default run-time settings.<br />
4.5.7    Data considerations<br />
Document the data considerations required for running the script: will the test use unique data or the same data within each iteration?  What data will cause the system under test to respond in ways that match the three requirements of deciding which script to emulate?).<br />
4.6    Customer approval<br />
Present samples from the Scripting design document to the stakeholders and the silo experts of the application. Make sure that the silo experts are satisfied with the level of the planned scripts and that the development direction is acceptable.</p>
<p>5    Script development<br />
Before starting the actual scripting development phase make sure that the following documents have been created and approved by the customer:<br />
The Performance testing design document<br />
The Scripting design document<br />
Don’t proceed with any massive scripting development before these documents are completed as it may lead to duplication of development efforts. For instance if no extensive mapping of the business processes was made and no critical transactions have been identified and approved by the stakeholders, most likely that the scripts would need to be completely re-written. In such cases there would be many iterations to align with inputs from the stakeholders and to deal with application aspects that were not covered by the first version of the scripts.<br />
5.1    Record a script<br />
In order to reduce the initial development script cycle, use the Performance Center VuGen technology to record the business process. The scripts produced from the recording must match the test design and use case scenarios.  Adherence to this match ensures that scripts can be reused in the future. The recorded scripts would serve as a framework for further script development.<br />
5.1.1    Script recording best practices<br />
Use the following options to enhance the script recording:<br />
Use the Multi-protocol option to record a test that utilizes several protocols (i.e. Web and Oracle).<br />
Additional manipulation options for Actions such as creating new actions, sorting, renaming and deleting actions are available for selected protocols (such as Web, Oracle NCA, SAP Web, Web Services and others). Older protocols may not have such options supported, therefore check in advance for availability of the action manipulation features for protocols you plan to use.<br />
Record several actions in a sequence (rather then recording one action, then stopping and starting with another action). This ensures continuity of correlation of session IDs and other data being passed in parameters within the script.<br />
Use previously created and tested scripts to create new functionality. Open the proven script, save it under a new name and modify it as needed.<br />
Note that every time a change is made in a script, that script needs to be recompiled.<br />
For further discussion on script recording considerations refer to KBA 28412.</p>
<p>5.2    Script structure considerations<br />
5.2.1    The default script structure<br />
By default, VuGen divides each script into three main blocks:<br />
Vuser_init<br />
This part of the script should hold all the initialization steps required to prepare the system for the transactions specified in the action block. Within the Vuser_init section, all recorded activities are executed once at the beginning of the script execution.  Activities in the Vuser_init are not repeated once executed, even if the script is programmed to iterate. Typical activities allocated to this section are one-time events based on the logic of the script.<br />
Action<br />
Here are located most of the business transactions (Vuser actions) intended for iteration . All the main functions are included here and are transparent to the VuGen user.<br />
Vuser_end<br />
This part holds all actions required to gracefully complete the emulation. Within the Vuser_end section, all recorded activities are executed once and only once at the end of the script execution.  Activities in the Vuser_end are not repeated once executed, even if the script is programmed to iterate. Typical activities allocated to this section are one-time events based on the logic of the script.<br />
For instance, in order to emulate a user’s entire working day which requires logging-into the application in the morning and logging-out at the end of the day, place all the steps emulating logging in and logging out into “Vuser_init” and “Vuser_end” sections respectively. All other actions are performed throughout the working day and are placed in the “Action” section.<br />
The “Action” itself can be broken into different blocks or you can add more actions to the default sections created by VuGen.</p>
<p>5.2.2    Script structure recommendations<br />
Follow the default script structure when you run performance tests using the same user. If several users are emulated you would have to record or script the log-in phase of the next user after the first user has logged-out.<br />
For detailed discussion about how to handle actions, transactions and blocks in VuGen, refer to the Runtime Settings chapter in the VuGen User’s manual.<br />
5.2.2.1    Script structure options<br />
The script must reflect the steps of a business process case but also be capable of interacting with the application in a manner real users would. A common pattern is a Vuser that needs to emulate a login, perform a number of test case iterations, logout and repeat the process again. Sometimes the Vusers are required to login and maintain an open user-session throughout the test run. To accommodate for actual system usage the engineer needs to consider the use (or not) of the Script’s vuser_init and vuser_end sections or even the use of additional functions. The following is a set of possible cases seen so far:</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2010/11/02/220/feed/</wfw:commentRss>
		<slash:comments>1835</slash:comments>
		</item>
		<item>
		<title>LoadRunner:Minimize your script debug time by using &#8220;On demand log functions.&#8221;</title>
		<link>http://www.performancecompetence.com/wordpress/2010/11/01/loadrunnersave-your-script-debug-time-by-using-on-demand-log-functions/</link>
		<comments>http://www.performancecompetence.com/wordpress/2010/11/01/loadrunnersave-your-script-debug-time-by-using-on-demand-log-functions/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 05:25:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.performancecompetence.com/wordpress/?p=203</guid>
		<description><![CDATA[More than often, I see people using Log settings available in Run-Time settings and completely ignore the function &#8220;lr_set_debug_messag(),&#8221; which I think Mercury has thoughtfully created, because it is genuinely useful in many occasions. Say, you&#8217;re dealing with a script with 5,000 lines and you have trouble correlating a certain dynamic string which you know [...]]]></description>
			<content:encoded><![CDATA[<p>More than often, I see people using Log settings available in Run-Time settings and completely ignore the function &#8220;lr_set_debug_messag(),&#8221; which I think Mercury has thoughtfully created, because it is genuinely useful in many occasions. Say, you&#8217;re dealing with a script with 5,000 lines and you have trouble correlating a certain dynamic string which you know for sure appears after a certain request in the 2000th line is fired to the AUT. Now, if you were to use just use the Extended Log option from the Run-Time settings of LoadRunner, then,  it would take huge about of time during replay to arrive till the 2000th line of the script, because it has to parse and display all the data returned from server onto the screen &#8211; right from the beginning of the script.</p>
<p>Here is when &#8220;<strong>lr_set_debug_messag()</strong>&#8221; comes in handy. All you have to do is place this function above the request which generates the response from where you intend to debug your script.  <span style="text-decoration: underline;">Make sure that you turn off Extended Log option in the Run-Time settings when you use this function. </span>This measure ensures that your extended log option is triggered only at places where you want them and hence will save you huge amount of time while debugging.</p>
<p>In the below example, I have created three functions and I generally place these functions inside global.h section of my script. During debug cycles, I just call &#8220;logs_on()&#8221; function when I need extended log(<em>with data returned from server and parameter substitution details enabled</em>) for a certain server response and I use &#8220;logs_off()&#8221; function at the line in the script from where I don&#8217;t want anymore logs to be displayed.  And I use &#8220;logclear()&#8221; function when LoadRunner doesn&#8217;t respond to logs_off() function(It is a known defect.)</p>
<pre><code>logs_on()
{
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG |LR_MSG_CLASS_RESULT_DATA| LR_MSG_CLASS_PARAMETERS , LR_SWITCH_ON );
}

logs_off()
{
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG |LR_MSG_CLASS_RESULT_DATA| LR_MSG_CLASS_PARAMETERS , LR_SWITCH_OFF );
}

void logclear(void)
{
unsigned int log_options = lr_get_debug_message();
lr_set_debug_message(log_options, LR_SWITCH_OFF);
return;
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.performancecompetence.com/wordpress/2010/11/01/loadrunnersave-your-script-debug-time-by-using-on-demand-log-functions/feed/</wfw:commentRss>
		<slash:comments>1985</slash:comments>
		</item>
	</channel>
</rss>

