0
votes

I want to send a a byte array which is not possible with the inbuilt HTTP Sampler.

So went ahead with BeanShell sampler.

But i found some time lagging in response of BeanShell Sampler

In my code I am sending a hard-coded byte array to the web service endpoint.

enter image description here

Is there a better approach like Java Request or JSR223 whose execution time is lesser than that of beanshell sampler

2
Has anyone tried it and found any of them faster ?Peter

2 Answers

3
votes

Well-behaved JSR223 Sampler with Groovy language and Compilation Cache feature enabled will work faster and have lesser memory footprint than Beanshell. Remember not to reference JMeter Functions or Variables in form of ${var} directly in Groovy script body.

Java Request sampler will the fastest one, however it will be harder to make changes as you will have to recompile your code, put it to JMeter Classpath and restart JMeter even for trivial change.

More information: Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For!


Particularly in your case you can use HTTP Raw Request instead of scripting.

1
votes

You should be able to enable Use multipart/form-data in HTTP Request Sampler and then send your array as parameter.

You can store byte[] in variable using Beanshell:

byte[] arr = new byte[] {...};
vars.putObject("myByteArray", arr);

After that just refer to variable as usual ${myByteArray}.