This class provides a standard method of reporting and analyzing performance monitoring information. It also provides a number of methods and measurements to help diagnose and analyze potential performance bottlenecks.

Performance Monitoring Utility

Programming and User Guide

Add the appropriate "perfmon" import and calls to your application.

    
/*
 * Copyright © 2001, Sun Microsystems Inc.
 * NAME: fasterhttp.java
 * DESCRIPTION: example java program using the perfmon package.
 */

/* import the PerfMon package */
import com.sun.midp.perfmon.*;

/**
 * Performance monitoring class for faster http tuning.
 */    
public class fasterhttp extends MIDlet 
    implements CommandListener, Runnable {
    
    /** Define midlet command object. */
    Command bye_command = new Command(Exit, Command.EXIT, 2);
    
    /** Define the perfmon instance. */
    private PerfMon perfmon;
    
    /** Constructor for fasterhttp class. */
    public fasterhttp() {
	
	/* Create the perfmon instance. */
	perfmon = new PerfMon("Protocol(reallyHttpConnection)");
	
    } /* end constructor */
      
    /**
     * Run method for the runnable thread object. 
     */
    public void run() 
	
	/* Start the performance analysis. */
	long start = perfmon.start("run()");
    
        while ((ch = input.read()) != -1) {
	    if (ch <= ' ') {
		ch = ' ';
	    }
	    
	    buffer.append((char ch);
			  }
	    
	    /* End the performance analysis. */
	    long end = perfmon.end();
	    
	    /* Report (stdout) performance analysis. */
	    perfmon.report(System.out);
	    
	} /* end run */
    
} /* end class */
	  

Use the "ENABLEPROFILING=true" macro when building.

% gnumake -e ENABLEPROFILING=true

Example Performance Monitor Report Output:

      ========================================================================
      Performance Monitor Tracing Report
      Application Name: [Protocol(HttpConnection)
      Report Date: [Mon, 12 Feb 2001 18:30:28 GMT (06:30 pm)]
      ========================================================================

      ------------------------------------------------------------------------
      Performance Monitor - Snapshot Analysis - 

      TimeStamp: [Mon, 12 Feb 2001 18:30:28 GMT (06:30 pm)]
      Class Name: [Protocol(HttpConnection)]
      Method Name: [run()]
      Comments: [read() performance monitoring[ line number 329 ]]
      Elapsed Time : [344] (milli-seconds)
      Classname: [Protocol(HttpConnection)]
      Instruction Count: [566266]
      Thread Switch Count: [0]
      Dynamic Object Count: [268]
      Dynamic Alloc Count: [57972]
      Dynamic Dealloc Count: [0]
      Garbage Collect Count: [0]
      GC Deferrals: [0]
      Maximum GC Deferrals: [0]
      Garbage Collect Rescans:[0]
      -----------------------------------------------------------------------
      Execution completed successfully
      1099922 bytecodes executed
      77 thread switches
      236 classes in the system (including system classes)
      1481 dynamic objects allocated (187364 bytes)
      6 garbage collections (4324 bytes collected)
      
	Total heap size 500000 bytes (currently 304672 bytes free)