How can I profile a Java Native Interface library written in C?
I know about the usual C profilers, but my question is how can I profile the whole set including the calls to the JVM methods which might be slowing down the program.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
After some research and testing with some of the methods proposed here I ended up using
sprof.Basically I followed the instructions available in this answer. Some comments:
LD_PROFILE_OUTPUTempty in order to get the result in/var/tmp/, otherwise the output file was not generated.LD_PROFILE=libXXXX.soTo get the profile I ran the Java code which loads and uses the native JNI library and I got a file with the profiling results in:
/var/tmp/libXXXX.so.profileOnce you have the file you can read it using the command:
sprof /path/to/libXXXX.so /var/tmp/libXXXX.so.profileThe results of the profiling follow the same template as
gprof. Here you can find a description of the contents and their meaning.