Convert a number to text

Another Mark Sibley function.

This converts a number into text. It relies on the number already being saved as a character string.

It’s currently set to create a title case word but could be amended to create an all upper or lower case word easily enough.

The words it creates are going to be mostly nonsense, however because it could have occasionally created a real word I removed all of the vowels to reduce the likelihood of creating any offensive words.

Copy and paste the following into a LoadRunner script to see it in action.

int ConvertNumberToText(char * sInput)
{
int i;
int c;
char n;
char sText[50];
char sCharacter[10];
char * sUpper[10];
char * sLower[10];

sUpper[0] = “B”; sUpper[1] = “C”; sUpper[2] = “D”; sUpper[3] = “F”; sUpper[4] = “G”;
sUpper[5] = “H”; sUpper[6] = “J”; sUpper[7] = “K”; sUpper[8] = “L”; sUpper[9] = “M”;

sLower[0] = “b”; sLower[1] = “c”; sLower[2] = “d”; sLower[3] = “f”; sLower[4] = “g”;
sLower[5] = “h”; sLower[6] = “j”; sLower[7] = “k”; sLower[8] = “l”; sLower[9] = “m”;

for (i = 0; i < strlen(sInput); i++) {

sscanf(sInput+i,”%c”,&n);
sprintf(sCharacter,”%c”,n);
c = atoi(sCharacter);

// This ensures that the first character is an upper case letter and that the rest are lower case.
// If you want a word that is either all upper or lower case then amend the appropriate [sUpper] or [sLower]
if (i == 0) {strcpy(sText,sUpper[c]);}
else  {strcat(sText,sLower[c]);}
}

lr_save_string(sText,”sName”);
lr_output_message(lr_eval_string(“Output:[{sName}]”));
}

Action()
{
int p = 459332;
char string[50];

itoa(p,string,10);

lr_save_string(“50328″,”sNumber”);

ConvertNumberToText(string);
ConvertNumberToText(“2168”);
ConvertNumberToText(lr_eval_string(“{sNumber}”));

return 0;
}

 

Reverse a text string in LoadRunner

Another Mark Sibley C/LoadRunner function.

This function takes a string of text and reverses it, turning [Peter Piper] into [repiP reteP]. I know it will have limited use but should you need it then here it is.

Copy and paste the following into a LoadRunner script to see it work:

//*******************************************************
int Reverse (char* Param, char* PName)
{
char n, Character[2000], Varname[2000];
char FullString[2000];
int i = strlen(Param);

strcpy(FullString,””);
strcpy(&n,””);

while (i >= 0)
{
sscanf(Param+i, “%c”, &n);
sprintf (Character,”%c”,n);

strcat(FullString, Character);

i–;
}

lr_save_string(FullString,PName);
}
//*******************************************************

Action()
{
lr_save_string(“ABC123456″,”Param”);
Reverse(lr_eval_string(“{Param}”),”NewParam”);
lr_output_message(lr_eval_string(“Changed [{Param}] to [{NewParam}]”));

lr_save_string(“Peter Piper”,”Param”);
Reverse(lr_eval_string(“{Param}”),”NewParam”);
lr_output_message(lr_eval_string(“Changed [{Param}] to [{NewParam}]”));

lr_save_string(“Fiddlesticks”,”Param”);
Reverse(lr_eval_string(“{Param}”),”NewParam”);
lr_output_message(lr_eval_string(“Changed [{Param}] to [{NewParam}]”));

return 0;
}

Performance Monitoring Best Practices (LoadRunner)

Leo Borisov (Functional Architect at HP) posted this to a LinkedIn discussion group on LoadRunner.
I just downloaded this document and it looks pretty good, it contains details of the best performace counters to monitor for Windows and UNIX systems and has details of different web servers such as WebLogic, WebSphere, IIS etc.

Leo’s LinkedIn posting which explains how to download the document is reproduced below.


I wanted to draw your attention to the fact that the recently released Service Pack 1 for HP LoadRunner and HP Performance Center includes a “Performance Monitoring Best Practices” book. This is the first installment in the “HP Performance Engineering Best Practices” series that HP Software and Solutions intends to release on the regular basis. We have always recognized the fact that having best practices and methodology would greatly simplify the life of performance engineers and managers, and now we are beginning to fill this need.

The book is available with the SP1 installation. Access it from the product documentation library, or from the Help menu.

Updated link:
http://lrhelp.saas.hpe.com/en/latest/help/PDFs/Monitoring_BP.pdf