The Jmeter GUI is nice. But to gain performance advantage, one may have to run it on command line as suggested by this tip. Also, you may have to be careful on how many threads to have, because hundreds of active threads may affect performance. This creates a problem: when HTTP transaction latency is high, say, hundreds of milliseconds, one needs to have a large number of VUsers (threads) to bring up the transaction rate, but a large number of threads may affect performance.
These are not the toughest problems with JMeter, the toughest problem is with parameterization or correlation: user needs to be really good at Java programming to do it. For many users with only basic programming background, this can be a serious challenge.
Netgend javascript makes things simpler:
- Don't have to worry about the number of threads, one system can support about 50,000 VUsers.
- Complex parameterization/correlation can be simple.
- Can view real time statistics on GUI while many VUsers are running.
The following question asked on a forum provides an excellent example. The question is on processing the following "complex" JSON message and extract the values of two fields "equipmentPartId", "compositePartName".
[
{
"equipmentPart":{
"allAttributes":{
"compositePartName":"SRW224G4P-K9-AU ",
"equipmentPartPhysicalSiteId":"73411",
"equipmentPartSiteId":73414,
"equipmentPartId":542024,
"productPartName":"SRW224G4P-K9-AU",
"equipmentPartName":"SRW224G4P-K9-AU"
}
},
"updatedTimeStamp":1337838775000,
"solutionEntityId":542227,
"solutionId":13959179,
"status":"validation ok",
"id":95509,
"createdTimeStamp":1337838666000,
"messages":", Non Configurable"
},
{
"equipmentPart":{
"allAttributes":{
"compositePartName":" UC560-T1E1-K9 ",
"equipmentPartPhysicalSiteId":"73411",
"equipmentPartSiteId":73412,
"equipmentPartId":542027,
"productPartName":"UC560-T1E1-K9",
"equipmentPartName":"UC560-T1E1-K9"
}
},
"updatedTimeStamp":1337838775000,
"solutionEntityId":542230,
"solutionId":13959179,
"status":"validationok",
"id":95510,
"createdTimeStamp":1337838666000,
"messages":", Non Configurable"
}
]
Here is a solution given for JMeter. import org.json.JSONArray;
import org.json.JSONObject;
String jsonString = prev.getResponseDataAsString();
JSONArray equipmentParts = new JSONArray(jsonString);
print("parsed json");
JSONArray parts = new JSONArray();
for(int i=0;i<equipmentParts.length();i++ ){
JSONObject equipmentPart = equipmentParts.getJSONObject(i).getJSONObject("equipmentPart");
print(equipmentPart.toString());
JSONObject allAttributes = equipmentPart.getJSONObject("allAttributes");
print(allAttributes.toString());
JSONObject part = new JSONObject();
print(allAttributes.getLong("equipmentPartId"));
part.put("partId",allAttributes.getLong("equipmentPartId"));
print(allAttributes.getString("compositePartName"));
part.put("partNumber",allAttributes.getString("compositePartName"));
// add more here
parts.put(part);
}
vars.put("jsonResponse", parts.toString());
An ordinary user have to really focus his/her attention to be able to follow it. With Netgend javascript, it's as simple as the following:
a = fromJson(data);
parts = [];
for (i = 0; i < getSize(a); i++) {
part.partId = a[i].equipmentPart.allAttributes.equipmentPartId;
part.partName = a[i].equipmentPart.allAttributes.compositePartName;
push(parts, part);
}
Here the compound variable "a[i].equipmentPart.allAttributes.equipmentPartId"
is based on the JSON message structure: at highest level, this JSON
message is an array, the each element in the array can be represented
by a[i], in each element, we have hierarchy like equipmentPart
-- allAttributes --equipmentPartId. Now you understand where the
compound variable comes from.
We believe parameterization/correlation should be made so simple that one doesn't need to be a guru on programming to do performance testing!
We believe parameterization/correlation should be made so simple that one doesn't need to be a guru on programming to do performance testing!
No comments:
Post a Comment