Profiling is a valuable tool in the JDeveloper toolbox that can help us in the diagnosis of performance issues by identifying code that consumes more time, code that is called more often (CPU profiling) and how memory is used by the deployed application (memory profiling).
To demonstrate this FAQ, let's create a sample Fusion Web Application (Web) based on the HR schema. Let's create an Employee entity from the EMPLOYEES table and an Employees view based on the Employee entity. Finally, let's bundle the Employees view in the HrAppModule application module.
For the ViewController let’s create a View Activity called Employees directly in the unbounded adfc-config task flow and an Employees.jspx JSF page for the Employees View Activity. Finally, let’s drag the Employees view from the HrAppModuleDataControl in the Data Controls and drop it onto the Employees.jspx JSF page as an ADF Form.
Configure the application security and deploy onto the standalone WebLogic server as explained in FAQ #3 - How to deploy an ADF application on a standalone WebLogic server directly from JDeveloper.
If you have any issues related to security or connecting to the database when running the deployed application, take a look at the references section at the bottom for a couple of pointers.
Once the application is deployed, let’s verify that all is well by accessing the application URL in your browser. For the sample application attached, enter the URL http://localhost:7001/JDeveloperFAQNo5/faces/Employees. You should see the log in screen below.
Log in using jdeveloper/jdeveloper1. The Employees page below will be displayed.
OK, let’s do some profiling now!
To enable remote profiling, bring up the Project Properties dialog and select Run/Debug/Profile. Select the Default run configuration from the list of Run Configurations and click Edit….
In the Profiler page under Tool Settings enter the name of the package in our code based on which the profiler results will be filtered. For the sake of our sample application enter com.jdeveloper.faq.*. This will enable the profiling of all the java classes that we generated in the ADF BC.
Click OK a couple of times to exit from the Project Settings dialog and then save the project settings.
From the Run menu select Attach to | CPU Profilee.
In the Attach to CPU Profilee dialog select Attach to Local Process, select the weblogic.Server process and click OK.
Once attached, the Profiling ViewController tab will be displayed. Click on the Begin Use Case to begin a new profiling use case. That is, the icon on the top left with the green run triangle.
In order to generate profiling metrics, play around with the sample application deployed on WebLogic. As you can see CPU statistics are generated. The Hotspots tab displays the methods in the code where most CPU is spent in terms of percentage of CPU time. The Call Stacks tab displays the metrics in a different view.
There are all sorts of other goodies you can do while profiling. For example, saving a use case and then comparing it with the new one that you run after you make certain code changes could be useful to verify the changes in performance.
Profiling an application is another tool that could be of use when looking for bottlenecks and performance improvements in your application. It’s easy to setup and use. Give it a try!
Until the next time, keep on JDeveloping!
http://radalcove.com/blog/?p=34 [at the bottom of the page]