Home > Guides > Core Developers Guide > Profiling |

Apache Struts 2 Documentation
Profiling
Edit Page Browse Space Add Page Add News

Profiling software looks for bottlenecks in program execution. In addition to the profiling services provided by IDEs and standalone profilers, the framework provides its own internal support for profiling.

## Profiling aspects

Struts2 profiling aspects involves the following :-

- ActionContextCleanUp
- FreemarkerPageFilter
- DispatcherFilter

- Dispatcher

- creation of DefaultActionProxy

- creation of DefaultActionInvocation

- creation of Action

- execution of DefaultActionProxy

- invocation of DefaultActionInvocation

- invocation of Interceptors
- invocation of Action
- invocation of PreResultListener
- invocation of Result

## Using

To enable profiling, first make sure that the `profiling` interceptor is applied to your action, like:

Then enable profiling using one of the following methods:

### Activate Through System property

This could be done in the container startup script eg. CATALINA_OPTS in catalina.sh (tomcat) or using "java -Dxwork.profile.activate=true -jar start.jar" (jetty)

### Activate Through code

This could be done in a static block, in a Spring bean with lazy-init="false", in a Servlet with init-on-startup as some numeric value, in a Filter or Listener's init method etc.

### Activate Through parameter

### Changing the activation parameter name

Set the `profilingKey` attribute of the `profiling` interceptor to the desired name:

Icon

Profiling activation through a parameter requires `struts.devMode` to be `true`.

## Filtering profile information

One could filter out the profile logging by having a System property as follows:

With this `xwork.profile.mintime` property, one could only log profile information when its execution time exceed those specified in `xwork.profile.mintime` system property. If no such property is specified, it will be assumed to be 0, hence all profile information will be logged.

## Write profiling code

One could extend the profiling feature provided by Struts2 in their web application as well.

### Using UtilTimerStack's push and pop

### Using a UtilTimerStack's ProfileBlock template

## Profiling Log files

Profiled result is logged using commons-logging under the logger named `com.opensymphony.xwork2.util.profiling.UtilTimerStack`. Depending on the underlying logging implementation, say if it is Log4j, one could direct the log to appear in a different file, being emailed to someone or have it stored in the db.

## Next: Debugging