Over a million developers have joined DZone.

Caudit : Audit your performance

· Performance Zone

Discover 50 of the latest mobile performance statistics with the Ultimate Guide to Digital Experience Monitoring, brought to you in partnership with Catchpoint.

Performance auditing is an important issue when you deal with an application which requires high performance. As I searched on the web, I could not find a way of doing that, so I have written a performance auditing library called Caudit.

Caudit is a simple library to log application performance, health and statistics in an organized manner. It has two basic audit types: stopwatches and quantities. Stopwatches are the ones which you keep track of the time passed for a specific operation. Quantities are variables that you want to monitor.

In general, I have used stopwatches to monitor my threads and quantities to monitor my queue sizes. Let's give some examples to make it more clear.

An example of a stopwatch.

//Mapping audit to integer is for performance
//(string comparison vs integer comparison)
  private final static int BASIC_STOPWATCH_ID = 
	Audits.mapAudit("example.basicStopwatch");

  public void tryOut(){
    final Stopwatch stopwatch = Audits.getBasicStopwatch(BASIC_STOPWATCH_ID);
    stopwatch.start();
    doSomeWork();
    stopwatch.stop();
  }

Output for this stopwach is as follows.

example.basicStopwatch : ElapsedTime[5679]

An example for quantity.

 private final static int NO_OF_RETRIEVED_ITEMS_ID = 
	Audits.mapAudit("example.noOfRetrievedItems");

  public void tryOut(){
    final LongQuantity quantity = Audits.
	getLongQuantity(NO_OF_RETRIEVED_ITEMS_ID);
    int size = retrieveItems().size();
    quantity.increment(size);
  }

Output for this quantity is as follows.

example.noOfRetrievedItems : Quantity[2631]

Dependency for caudit as follows.

<dependency>
  <groupId>com.cetsoft</groupId>
  <artifactId>caudit</artifactId>
  <version>0.0.7</version>
</dependency>

What I do with those stopwatches and quantities is to output to audits to the console, log and etc. For more information, please visit https://github.com/Cetsoft/caudit/ and fork me on github.



Is your APM strategy broken? This ebook explores the latest in Gartner research to help you learn how to close the end-user experience gap in APM, brought to you in partnership with Catchpoint.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}