FileDocCategorySizeDatePackage
NotificationPerformanceTest.javaAPI DocGlassfish v2 API4113Fri May 04 22:23:54 BST 2007com.sun.enterprise.management.base

NotificationPerformanceTest

public final class NotificationPerformanceTest extends com.sun.enterprise.management.util.jmx.JMXTestBase

Fields Summary
private static final String
IMPL_CLASSNAME
Constructors Summary
public NotificationPerformanceTest()

    
		
	 
	
	
Methods Summary
private javax.management.ObjectNamecreateTestDummy(java.lang.String name)

	    ObjectName objectName =
	        Util.newObjectName( "NotificationPerformanceTest:name=" + name );
	    
	    final MBeanServerConnection conn = getMBeanServerConnection();
	    
	    if ( ! conn.isRegistered( objectName ) )
	    {
    	    objectName  =
    	        conn.createMBean( IMPL_CLASSNAME, objectName ).getObjectName();
	    }
	    
	    return objectName;
	
public voidtestNotificationPerformance()

	    final ObjectName    objectName  = createTestDummy( "testNotificationPerformance" );
	    
	    final TestDummyMBean  test  = newProxy( objectName, TestDummyMBean.class );
	    
	    final int   ITER    = 10;
	    final int   COUNT   = 1024 * 1024;
	    
	    for( int iter = 0; iter < ITER; ++iter )
	    {
    	    final long elapsed  =
    	        test.emitNotifications( "NotificationPerformanceTest.test", COUNT );
    	    
    	    final float rate    = (elapsed == 0) ? (float)0.0 : (1000 * ((float)COUNT / (float)elapsed));
    	    final String rateString = (elapsed == 0) ? "N/A" : "" + (int)rate;
    	    
    	    System.out.println( "Millis to emit " + COUNT + " Notifications: " + elapsed + 
    		    " = " + rateString + " notifications/sec" );
	    }