I have written a Java based rest API project. I want to test the performance for the API.
Here performance can be divided into two.
I know how to test or measure #1 but I am not sure how to measure #2.
More info for #2
Suppose I have a method which is mapped to rest end point.
I want to know how much time was spent in
Thanks
For request-response performance testing you can use SoapUI or Jmeter:
http://www.soapui.org/rest-testing/getting-started.html
For code execution time, "profiling" is the best option, because it doesn't require code modification, but it can be difficult for non expert users.
https://visualvm.java.net/
An old fashion way, modifying code is to log (with Log4j or similar) the execution time of the methods:
long startT = System.nanoTime();
//Code you want to measure
long endT = System.nanoTime();
long executionTime = (endT - startT); //divide by 1000000 to get millisecs.
//Log this in specific category and level, so you can turn it on/off depending on your needs
For your performance tests I would recommend to use JMeter (http://jmeter.apache.org/) and if you suspect bottlenecks I would recomment to create a java profile using a tool like jprof (http://perfinsp.sourceforge.net/jprof.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With