New GESHI syntax highlighter for LoadRunner 11.5

In August 2010, I put Stuart Moncrieff’s syntax highlighter on my website so that I could easily copy and past LoadRunner code into documents in the correct colours. Since LoadRunner 11.5 was released with a new compiler and different colours in the script editor, I thought that it was time for an update.

The links below take you to the old and new GeSHi pages which format text in LR 9.x and LR 11.x colours.

https://bish.co.uk/geshi/LR_9_5.php
LoadRunner 9.5 script editor colours

https://bish.co.uk/geshi/LR_11_5.php
LoadRunner 11.5 script editor colours

 

Whilst this may be useful to you, you may also be pleased to know that the new editor supports pasting directly from VUGen into Word or other programs and the source formatting is preserved. This is great if you want to insert code snippets into documents and keep the code readable.

 

Evaluate string content in LoadRunner

This little bit of code was passed to bish.co.uk by Mark Sibley. I thought that I’d reproduce it here because it looked useful. You can use this function to check whether a captured string contains a certain piece of text, this allows you to check for the presence of an error “word” when your captured string may not always use the same boundaries.

This gives similar functionality as web_reg_find but without the overhead of searching HTML as it is returned to the vUser, it allows “post processing” of captured text which tends to have a lower performance hit on the vUser.

 
	// Use this if you want to check whether something you captured contained a piece of text
	// It's handy if the same word appears in more than one type of error or warning message but doesn't // always have the same boundaries.
	if ((char *)strstr(lr_eval_string("{cCapturedString}"), "rejected") != NULL)
	{
		lr_save_string(lr_eval_string("DATA USED:: Rows:[{cRowText}] Param Name:[{sCatParamTitle}] sCatTxt:[{sCatTxt}]"),"sDataUsed");

		lr_fail_trans_with_error("Expected:[%s] %s",Expected,lr_eval_string("Received:[{cCaptured}] User:[{pUserID}] I:[{pIteration}] T:[{sTransaction}] {sDataUsed}")); 
		lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE,LR_FAIL);
	}
	else
	{
		lr_vuser_status_message(lr_eval_string("User [{pUserID}] completed I:[{pIteration}] T:[{sTransaction}]"));
	}

How many vUsers ran in a test?

Recently a colleague of mine working at a major UK bank was asked to find out ways that the number of vUsers in a test could be recorded so that the cost of LoadRunner licences could be charged back to the project or department who requested a particular test. I had a quick look arounf the LoadRunner results set and found a file containing information which can be used to calculate this.

In the results folder there is a sub-folder called “Data”. This contains a file called vurun.txt.
The file contains information about the vUser profile for a test.

A sample file looks like this…..

1296043739         0              1296043742

1296043742         1              1296043745

1296043745         2              1296043748

1296043748         4              1296043751

1296043751         2              1296043753

1296043753         1              1296043756

1296043756         0              1296043759

 

The first number in each row is the epoch time (in seconds).
The second number in each row is the number of running vUsers.
The third number in each row is also epoch time.

Each row basically contains 3-seconds-worth of information. (I presume that this is the default sampling interval).

In the example above (which I’ve made up), the test started and no users ran in the first 3 seconds. The vUser count was 1 in the next 3-second period, 2 in the one after that etc. You could either calculate an average from the middle column to charge per vUser or pull out the largest number and charge based on that.

The contents of this file can be pasted into an Excel spreadsheet and the “text to columns” option can be used to split the information in the file into three columns.
The LoadRunner AVERAGE and MAX functions can be used to return the average or maximum number of running users.

You can use tools such ashttp://www.epochconverter.com/ or https://bish.co.uk/epoch.htm to convert the epoch times in the file to the Gregorian calendar.