You might have noticed that once you have started your load test, it is possible to increase the number of transactions per hour by adding virtual users, but not by changing the pacing time.
The VuGen Pacing runtime setting is only read at the start of the test so, to change it, it is necessary to stop the test, then make the change and restart.
Fortunately (if you need to), you can write code to control the pacing of your virtual users instead of using the runtime settings. If you write code to pick up a pacing setting from a file, and check the file on each iteration, then you can cause your script to delay for the right amount of time to meet your desired transaction rate.
Obviously, if you are controlling the pacing yourself, you should have the Pacing runtime setting set to “start new iteration as soon as the previous iteration ends”. And if you are using think time for the pacing delay, you should have the Think Time runtime setting set to “replay think time” (or use think time that can’t be ignored).
Action()
{
merc_timer_handle_t timer;
double duration;
double pacing_time;
// Read desired pacing timer from a text file.
// The text file should contain the number of seconds to be used for pacing.
pacing_time = (double)jds_read_pacing_time("C:\\TEMP\\vugen_pacing.txt");
// Start the timer.
timer = lr_start_timer();
// Call Action function that you want to control pacing for.
// Note that if you do it this way (rather than putting the pacing code at the start and end of the
// Action), then you need to first go to the Run Logic area of the runtime settings, and right-click the
// Search Action and select "remove item" from the context menu.
Search();
// Stop the timer
duration = lr_end_timer(timer);
// Wait for the necessary number of seconds to elapse before starting the next iteration.
if (duration < pacing_time) {
lr_think_time(pacing_time - duration);
} else {
lr_error_message("Pacing time exceeded. Target: %G seconds. Actual: %g seconds", pacing_time, duration);
}
return 0;
}
// Read pacing time from a file. Returns time in seconds (whole seconds only).
// Note that file can be on a shared network drive.
int jds_read_pacing_time(char* file_name) {
long fs; // file stream
int number_from_file;
// Open the file for reading
fs = fopen(file_name, "r+");
if (fs == NULL) {
lr_error_message("Error opening file: %s", file_name);
return -1;
}
// Read number from file.
if (fscanf(fs, "%d", &number_from_file) != 1) {
lr_error_message("Error reading number from file: %s", file_name);
return -1;
}
fclose(fs);
return number_from_file;
}
2 Comments
Comments are closed.
We can control pacing in Run time setting itself –
Runtime setting -> Pacing
start new iteration At {fixed} intervals every {60.000} sec.
If the iteration completes within 40 sec, vuser will wait for 20 more sec.
If the iteration completes after 60 sec, vuser will not wait and continues the next iteration.
Shakul, please reread the article as you seem to have missed the point entirely. Besides this how are you maintaining your throughput if your iteration completes after the 60 seconds has elapsed as you mention? What it it takes 70, 80, 90 seconds to complete an iteration?