Think time that cannot be ignored
Someone asked me once if there was a way of putting think time into a VuGen script that could not be ignored by changing the runtime settings.
There are very few situations I can think of where this would be a good idea, but it is certainly possible to force a VuGen script to pause for a specified number of seconds irrespective of the script’s runtime settings.
The windows API provides a sleep function that can be substituted for lr_think_time, however you will need to load the Kernel32 DLL before you can use the function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int rc; rc = lr_load_dll("Kernel32.dll"); // needed for sleep() if (rc!=0) { lr_error_message("Error loading DLL"); } lr_start_transaction("sleep time"); sleep(10000); // sleep time in milliseconds // Check whether VuGen regards sleep time as "wasted time" lr_output_message("wasted time: %d", lr_get_transaction_wasted_time ("sleep time")); lr_end_transaction("sleep time", LR_AUTO); |
Note that VuGen does not regard sleep time as “wasted time”, which can be determined using the lr_get_transaction_wasted_time() function from inside the transaction.
While this is a nice example of using a DLL to call non-VuGen functions, the only real-world example of when the sleep() function may be useful is when you have a BPM script that polls another application within a loop. Using sleep() instead of lr_think_time() would mean that no-one can accidentally cause your script to generate excessive load on the server by polling very quickly (using the “ignore think time” or “limit think time to x seconds” runtime settings).
Related posts:
- Persistent Data in VuGen with MySQL One of the main drawbacks with VuGen is the inability...
- Parameterising Unix/Posix timestamps in VuGen A common question from people creating web-based VuGen scripts is...
- Harvesting file names with VuGen VuGen isn’t just a tool for load testing and application...
- VuGen Code Snippets This is a repository of code snippets. Please send me...
- Changing LoadRunner/VuGen log options at runtime LoadRunner has a whole bunch of logging options. These can...
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
February 3rd, 2010 at 3:11 pm
Note that Java vusers have a method they can call that does this for them.
C-based vusers will have to import Kernel32.dll and make the Win 32 API call directly.