[英]How to profile Native JNI library
How can I profile a Java Native Interface library written in C? 如何剖析用C编写的Java本机接口库?
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. 我了解通常的C探查器,但是我的问题是我如何探查整个集合,包括对JVM方法的调用,这可能会使程序变慢。
After some research and testing with some of the methods proposed here I ended up using sprof
. 经过对本文提出的一些方法进行研究和测试之后,我最终使用了
sprof
。
Basically I followed the instructions available in this answer . 基本上,我按照此答案中的说明进行操作。 Some comments:
一些评论:
LD_PROFILE_OUTPUT
empty in order to get the result in /var/tmp/
, otherwise the output file was not generated. /var/tmp/
获得结果,我必须将LD_PROFILE_OUTPUT
留空,否则将不会生成输出文件。 LD_PROFILE=libXXXX.so
LD_PROFILE=libXXXX.so
To 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: 为了获取配置文件,我运行了Java代码,该代码加载并使用了本机JNI库,并且我得到了一个带有分析结果的文件:
/var/tmp/libXXXX.so.profile
Once you have the file you can read it using the command: 获得文件后,可以使用以下命令读取文件:
sprof /path/to/libXXXX.so /var/tmp/libXXXX.so.profile
The results of the profiling follow the same template as gprof
. 分析的结果与
gprof
遵循相同的模板。 Here you can find a description of the contents and their meaning. 在这里您可以找到内容及其含义的描述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.