Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
5255 Discussions

profiling java code which is being called from native code

k_g_v_s_prasad
Beginner
1,298 Views
Hello,
I am able to profile native code which is being called from java code. But I could not able to profile java code which is being called from native code.

I have written a win32 application in Delphi. This application calls java methods using JNI. I want to find hotspots in both Delphi code and java code.

Friends please suggest me how to do this.
regards,
prasad.
0 Kudos
4 Replies
Haim_C_Intel
Employee
1,298 Views
Hi

To load the profiler dll with the JVM you need to specify "-Xrunjavaperf" in the options field of the JavaVMInitArgs structure when you load the JVM.
(for call graph you need to specify "-Xrunjavaperf:cg")

I'll demonstrate it in C++ sample, but I guess it's the same for Delphi:
#include

#define USER_CLASSPATH "." /* where Prog.class is */

main() {
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
jint res;
JavaVMOption options[2];
options[0].optionString = "-Xrunjavaperf:cg";
options[1].optionString = "-Djava.class.path=" USER_CLASSPATH;

vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 2;

/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0) {
printf("Error loading VM!! ");
return 1;
}

jclass cls = env->FindClass("JNITest");
jmethodID mid = env->GetStaticMethodID(cls, "test", "()V");
env->CallStaticVoidMethod(cls, mid);

jvm->DestroyJavaVM();

return 0;
}

I tried it with sun JVM 1.4.2 and I had segmentation fault, but with BEA JRockit 8.1 sp1 and IBM 1.3.1 it worked fine.

I hope it answer your question.
0 Kudos
k_g_v_s_prasad
Beginner
1,298 Views
Hi Haimc,
Thanks for the reply. Putting "cg" in command line option is new to me. I will try this and share the experience.
Can u please also tell me what is the command line option for sampling..?
Regards,
Prasad.
0 Kudos
Intel_C_Intel
Employee
1,298 Views
Sampling is the default. Do not specify ":cg"
0 Kudos
Aaron_C_Intel
Employee
1,298 Views
Hi all,

I'm trying to do the same thing, but I don't understand is how to configure the VTune activity. Do I creata Java sampling activity? If so, Do I choose Application, Script or Applet?

Maybe I'm going down the wrong path?

Thanks
Aaron
0 Kudos
Reply