Thursday, July 9, 2009

Write a parameter to a text file in loadrunner script

char *filename = "c:\\myfilename.txt";
long file_stream;
vuser_init()
{

if ((file_stream = fopen(filename, "a+")) == NULL) //open file in append mode
{
lr_error_message ("Cannot open %s", filename);
return -1;
}


fprintf (file_stream, "%s\n", lr_eval_string("THE PARAMETER IS :{Parameter}")); //Parameter is parameter name to be written in a file

Return 0;

}

vuser_end()
{
fclose(file_stream);//dont forget to close file_stream in vuser_end scetion
return 0;
}

Thursday, July 2, 2009

monitor cpu and memory utilization of an individual process in windows

Sometime it is required to measure cpu utilization of a process instead to cpu utilization of whole machine in windows.
This is very much possible with PerfMon tool in windows
Steps to follow
1: Launch perfmon
2:Click Performance Logs and Alerts tree on left most window
3:Select Counter Logs from tree structure
4: Right click Counter Logs and select "New Log setting"
5: Give any name for new logs.
6: Click on Add objects tab.
7:Select Process from the list then click on Add then close.
8:Click "Log Files" tab at the top.
9:Select Log File Type as csv or tsv,as per your requirement
10: You are all set to go by default log file will be saved in c:\perfLogs folder