Menu

mExec4j

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.

** 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 : **

INFO: Method Call : Method Name - onApplicationEventArguments : [org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.ClassPathXmlApplicationContext@7bd9f2: startup date [Fri Sep 28 17:32:26 IST 2012]; root of context hierarchy]],Output : null , Execution Time : 0 milliseconds , Elapsed Heap Space 0 bytes, Total Heap Space : 66191360 bytes, Free Heap Space : 63378808 bytes
Start of function.
28 Sep, 2012 5:32:27 PM com.contour4j.aop.aspect.SimpleContour profile
INFO: Method Call : Method Name - iDontKnowAboutAspectsArguments : [],Output : null , Execution Time : 24 milliseconds , Elapsed Heap Space 0 bytes, Total Heap Space : 66191360 bytes, Free Heap Space : 62719416 bytes
This is a Dummy function.
End of function.
testinggg for oyur codee
28 Sep, 2012 5:32:31 PM com.contour4j.aop.aspect.SimpleContour profile
INFO: Method Call : Method Name - testMethodArguments : [],Output : null , Execution Time : 3867 milliseconds , Elapsed Heap Space 121896960 bytes, Total Heap Space : 188088320 bytes, Free Heap Space : 65970464 bytes
28 Sep, 2012 5:32:31 PM com.contour4j.aop.aspect.SimpleContour profile
SEVERE: Method Call : Method Name - testMethodArguments : [] Exceeded Max Execution Time (300 milliseconds) configured
28 Sep, 2012 5:32:31 PM com.contour4j.aop.aspect.SimpleContour profile
SEVERE: Method Call : Method Name - testMethodArguments : [] Exceeded Max Heap Space (20 bytes) configured