Menu

Home

Karthikeyan Kanagaraj
mExec4j is a lightweight method execution profiler. It helps the developer to optimize the code by monitoring the
* Execution Time
* Heap Space Usage
* parameters
* outcome
of the methods in runtime.
[[download_button]]
[[project_admins]]

** Who can use mExec4j? **

Any Spring framework based can use mExec4j by just plugging it as a dependency.

** How to Use mExec4j ? **

Step 1: Add mExec4j.jar in classpath (if you are using maven, then install this jar in your repository and add it to dependency)

Step 2: Place the mexec4j.properties and set the property values as you desire (But dont change the property names)

Step 3: Add <import resource="classpath:mexec4j.xml"> in your application context of spring application</import>

Final Step is to add the dependency :

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.1.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib-nodep</artifactId>
        <version>2.2.2</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.6.12</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.12</version>
    </dependency>

The Jar versions can vary, If you are not using maven, then add those jars manually.

** Snapshot - logs : **

28 Sep, 2012 5:41:32 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@71dc3d: defining beans [businessLogic,testLogic,aopAspect,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.aspectj.AspectJPointcutAdvisor#0,pointcut,contourConfig,aopContour]; root of factory hierarchy
28 Sep, 2012 5:41:32 PM com.mexec4j.aop.aspect.SimpleMethodOutliner profile
INFO: Method Call : Method Name - onApplicationEventArguments : [org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.ClassPathXmlApplicationContext@1ccb029: startup date [Fri Sep 28 17:41:31 IST 2012]; root of context hierarchy]],Output : null , Execution Time : 0 milliseconds , Elapsed Heap Space 0 bytes, Total Heap Space : 57278464 bytes, Free Heap Space : 54597712 bytes
--- Method One Execution ----
28 Sep, 2012 5:41:32 PM com.mexec4j.aop.aspect.SimpleMethodOutliner profile
INFO: Method Call : Method Name - methodOneArguments : [],Output : null , Execution Time : 26 milliseconds , Elapsed Heap Space 0 bytes, Total Heap Space : 57278464 bytes, Free Heap Space : 53932184 bytes
 ---- Method Two Execution ---- 
28 Sep, 2012 5:41:35 PM com.mexec4j.aop.aspect.SimpleMethodOutliner profile
INFO: Method Call : Method Name - testMethodTwoArguments : [],Output : null , Execution Time : 2553 milliseconds , Elapsed Heap Space 118882304 bytes, Total Heap Space : 176160768 bytes, Free Heap Space : 53797352 bytes
28 Sep, 2012 5:41:35 PM com.mexec4j.aop.aspect.SimpleMethodOutliner profile
SEVERE: Method Call : Method Name - testMethodTwoArguments : [] Exceeded Max Execution Time (300 milliseconds) configured 
28 Sep, 2012 5:41:35 PM com.mexec4j.aop.aspect.SimpleMethodOutliner profile
SEVERE: Method Call : Method Name - testMethodTwoArguments : [] Exceeded Max Heap Space (20 bytes) configured