Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Using VTune™ Amplifier XE to profile Java applet from Apache-tomcat

$
0
0

Some users develop Java applets working on Tomcat, and hope that VTune™ Amplifier XE can get performance data on these Java applets.

First at all, we need to install JDK, I uses Java version 1.7.0_11, and you should set environment like as:
export JRE_HOME=/home/peter/jdk1.7.0_11/

Secondary, download apache-tomcat-7.0.40, extract it in any folder. Usually you don’t need to do more things, tomcat can work by using a pair of sh files.
Apach-tomcat-7.0.4/bin/startup.sh
Apach-tomcat-7.0.4/bin/shutdown.sh

You can use “ps axuwf | grep java” to find a java service process (tomcat) working.
You also can use “ps axuwf | grep java” to find a tcp service is working (listening) via 8080 port, such as
tcp        0      0 :::8080                     :::*                        LISTEN      12753/java   

If tomcat starts up successfully, you can use http://localhost:8080 in browser to see welcome page. That is, tomcat http applet service is working.

Next step, before compiling your Java http servlet application, should copy servlet-api.jar from tomcat to your JDK library directory. For example:
cp apache-tomcat-7.0.40/jre/lib/servlet-api.jar /home/peter/jdk1.7.0_11/jre/lib/ext  

Then, you can compile your java application to generate classes, such as –
javac –g calc.java

You need to copy whole calc directory and calc.war file to apache-tomcat-7.0.40/webapps. Also, you might need to write other jsp file or index.html, etc under calc directory. Finally compact all contents into .war file, like as:
jar cvf calc.war calc

[I attached example java file, jsp file and index.html in my example "calc"]

Now we can start to use VTune™ Amplifier XE 2013 to collect performance data on http servlet . The steps are:
1. Apach-tomcat-7.0.4/bin/startup.sh ; start tomcat service
2. ps -ae | grep java ; find target java process running
3. Use firefox or other browser to input http://localhost:8080/calc,  - for example.
4. Click “To a servlet.” to run calc class.
5. Run “amplxe-cl -collect lightweight-hotspots -knob enable-stack-collection=true -knob enable-call-counts=true -search-dir all:rp=/home/peter/apache-tomcat-7.0.40/webapps/ -target-pid 3700 -duration 30”
6. You will see result directory generated, then use amplxe-gui to open result.

If you don't run Apach-tomcat again,do

Apach-tomcat-7.0.4/bin/shutdown.sh

Please note if you use hotspots to profile target process, the result may be disappointed, because hot function is showed “[Outside any known module]”

  • VTune Amplifier XE Java Tomcat
  • Developers
  • Students
  • Linux*
  • Server
  • Java*
  • Intel® VTune™ Amplifier XE
  • Optimization
  • Server
  • URL
  • Code Sample
  • Getting started
  • Improving performance

  • Viewing all articles
    Browse latest Browse all 3384

    Trending Articles



    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>