Generating random extents using JMETER testing...

2548
2
08-30-2010 11:47 AM
BillZborowski1
New Contributor
Hi Guys,

I'm doing some performance testing on a ImageService through AGS WMS and I'm trying to generate random extents.  I've tried a very overly simplistic javascript to do this based on the max extent, however the images coming back get scewed, etc.  This is not an ArcServer or ImageServer problem, but rather that my random number generator may be giving me back unrealistic extents.

Is there a better method if, given a max extent, projection, image length, and image width, of generating USABLE extent values?

My current code:

/**
 * Generates a random number that falls between a max and min value.
 * @param minValue The minimum value.
 * @param maxValue The maximum value.
 * @param precision The floating-point precision value.
 * @return A random float number between the min and max value.
 */
function randomFloatBetween(minValue,maxValue,precision){
 if(typeof(precision) == 'undefined'){
  precision = 2;
 }
 return parseFloat(Math.min(minValue + (Math.random() * (maxValue - minValue)),maxValue).toFixed(precision));
}

//set the maximum extent.
var ymin = parseFloat("43.893368");
var xmin = parseFloat("-76.201033");
var ymax = parseFloat("47.785260");
var xmax = parseFloat("-69.957141");

//generate 2 random x points.
var xvalue = randomFloatBetween(xmin, xmax, 6);
var xvalue2 = randomFloatBetween(xmin, xmax, 6);

//generate 2 random y points.
var yvalue = randomFloatBetween(ymin, ymax, 6);
var yvalue2 = randomFloatBetween(ymin, ymax, 6);

//set the NEW xmin, xmax, ymin, ymax values.
var minX = 0;
var minY = 0;
var maxX = 0;
var maxY = 0;
if(xvalue >= xvalue2) {
 maxX = xvalue;
 minX = xvalue2;
} else {
 maxX = xvalue2;
 minX = xvalue;
}
if(yvalue >= yvalue2) {
 maxY = yvalue;
 minY = yvalue2;
} else {
 maxY = yvalue2;
 minY = yvalue;
}

vars.put('bbox', minY+','+minX+','+maxY+','+maxX);



Bill
0 Kudos
2 Replies
PeterBecker
Esri Regular Contributor
Following Python based code may help you.
It takes as input the extents and pixelSize range values and Cols & Rows.
You should be able to covnert easily. Ensure you define in the request the Width (Cols) and Height (rows).
0 Kudos
DmitriT
New Contributor
It may be due to Javascript engine performance problems. It is recommended to use JSR223 Sampler and Groovy language for scripting as Javascript/Beanshell have well-known performance constraints as their "Scriptable" interface implementations don't implement compilable and groovy does.

So groovy code can be almost as fast as native Java code.

See JMeter Extensions Performance Comparison for details.
0 Kudos