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.

1. Request to response time.
2. Actual code execution time.

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

1. Parsing data to method params
2. Executing the code in the method
3. Amount of time spent in converting the response back to JSON

Thanks