VUGen as an editor is a joke. Blah blah, it is just crappy (my opinion of course). I got Eclipse to work for me building VUGen scripts and running by calling some .bat files; I don’t remember the details, it has been awhile since I messed with it because I was having slowness problems due to file permission issues I was having at the time.
So right now I’m doing some refactoring of scripts. These scripts are in C, with API functions to work with http request/response and helper functions for dealing with parameters. I believe that it runs in an c-based “managed environment” so it is not 100% ANSI C (whatever the hell that means!) I’m not going to go into details on what the restrictions are…
Anyway, I want to talk about structuring C code. I’m by no means an C expert, because I mostly programmed in C++, and as you know, I suck at C++! But I always believed that you do not have to have all the object-oriented bullshyte in order to have modular, relatively robust, safe and sound code…with ample supply of KISS and DRY. Yeah–that’s the theory. It take tons of practice and patience to be able to apply all that 100%; it also takes a little bit of common sense too. Also, I like to mention I’m putting several different code path inside a single script, because I want to implement a distribution based system, which follows real production usage patterns. As of now, I only have hit-based, url-bound (no parameter information) usage patterns from logs. What I need is the graph of usage–that is something I will have to do in the future.
The truth is though: no one gave a damn about load testing scripts. I don’t even give damn about it. It’s semi-useful right now and in the future it can become somewhat useful. But in the END it all comes down to the actual App. No one gives a damn about it, unless you are working on the App!!! That makes sense. That’s keeping it real. I just want to do a semi-decent job at re-factoring, so we don’t have to mess with it much in the future–I want to learn other things. (I don’t want to sound like I’m enthusiastic about my job, because I’m not. But they pay me so I try to do the best I can. I’m a work whore, I know).
What I have been doing pretty good (I think):
-Having manager structures. It’s not fully blown C structures (i.e. with functions) so they only contain data. For example, I found they are nice for managing transaction and/or parameter names. So I keep them in a single place. It’s like a resource file! This allows me to easily implement chronological based transaction naming (yes, I looked into automating with macros).
-Having nice “leaf” functions that does one thing and are based on parameters for control.
So I can do something like:
//login
//LoadDataController
//Make http request for data and handle other things
//UsagePatternController: run N iterations
enum CodePath
{
codepath1,
codepath2,
codepath3
}randomChoice;
randomChoice = (enum CodePath)getChoiceBasedOnUsage();
switch(randomChoice)
{
case choice1:
prepare to parse something.
getReadyToParseSomething();
doReallySweetLeafFunction("Parameters for control");
validateParsedData();
case choice2:
doSomeOtherThings()
doReallySweetLeafFunction("Parameters for control");
..
...
...
default:
}
//Logout
So you read it this far huh? WOW. I’m sorry I usually don’t proof read my blogs. And you know I can drag on and on and on about just bullshyte. WTF. I’m going jogging.