Package measurements.suites

Source Code of measurements.suites.ProceedMeasurements1_micro_1_LongO_aj

// $Id: ProceedMeasurements1_micro_1_LongO_aj.java,v 1.1 2008/11/18 10:43:24 anicoara Exp $
// ==================================================================

package measurements.suites;

import junit.framework.Test;
import junit.framework.Assert;
import ch.ethz.inf.util.junit.PerformanceTest;
import ch.ethz.inf.util.junit.PerformanceTestSuite;
//import ch.ethz.prose.jikesrvm.JikesRVMPerformanceTest;


/**
* JoinPoint micro-measurements.
*
* Performance micro-measurements tests for method boundaries,
* fields accesses and modifications, exception handlers:
*
* 1) INVOKEVIRTUAL -> invoke a normal method
* 2) SYNC INVOKEVIRTUAL -> invoke a normal but synchronized method
* 3) INVOKEINTERFACE -> invoke a method through an interface
* 4) INVOKESPECIAL -> invoke a private method
* 5) INVOKESTATIC -> invoke a static method
*
* Each test is executed "RUNS" times.
*
* @author Angela Nicoara
*/
public class ProceedMeasurements1_micro_1_LongO_aj extends PerformanceTest {
//public class ProceedMeasurements1_micro_1_LongO_aj extends JikesRVMPerformanceTest {

  public boolean checkAssert = true;

  public static int counter = 0;
  public int x = 0;

  // INVOKEVIRTUAL
  public void localMethod() { x = counter; }
  public void localMethodLongO(Object ob1, Object ob2) { x = counter; }
  public void localMethodLongI(int ob1, int ob2) { x = counter; }
  public void localMethodLongL(long ob1, long ob2) { x = counter; }
  public void localMethodLongD(double ob1, double ob2) { x = counter; }

  // INVOKESPECIAL
  private void privatelocalMethod() { x = counter; }
  private void privatelocalMethodLongO(Object ob1, Object ob2) { x = counter; }
  private void privatelocalMethodLongI(int ob1, int ob2) { x = counter; }
  private void privatelocalMethodLongL(long ob1, long ob2) { x = counter; }
  private void privatelocalMethodLongD(double ob1, double ob2) { x = counter; }

  // INVOKEINTERFACE
  protected JoinPointTestInterface obInterface = new JoinPointTestClass();

  // SYNC INVOKEVIRTUAL
  protected JoinPointTestClass obSync = new JoinPointTestClass();

  //===============================================================

  public ProceedMeasurements1_micro_1_LongO_aj(String name) {
    super(name);
    //RANGE = new int[] { 100000000 };
    //RANGE = new int[] { 1000000 };
    //RANGE = new int[] { 1, 1000000 };
    RANGE = new int[] { 1, 100000 };
  }

  protected void setUp() throws Exception {
    counter = 0;
    x = 0;
  }

  protected void tearDown() { }

  //=====================================================   
  // Method arguments: (Object, Object)
  //=====================================================

  // 3) INVOKEVIRTUAL - call to empty weaver because of on active, unlocked joinpoint
  public void testVirtualMethodRedefinition_LongO() {
    Object obj = new Object();

    localMethodLongO(obj, obj);

    startChronometer();
    for (int i = 0; i < RUNS; i++) localMethodLongO(obj, obj);
    stopChronometer();

    if (checkAssert) assertEquals("Hook notifications", RUNS+1, counter);
  }

  //=====================================================

  // 3) SYNC INVOKEVIRTUAL - call to empty weaver because of on active, unlocked joinpoint
  public void testSyncVirtualMethodRedefinition_LongO() {
    Object obj = new Object();

    obSync.syncMethodLongO(obj, obj);

    startChronometer();
    for (int i = 0; i < RUNS; i++) obSync.syncMethodLongO(obj, obj);
    stopChronometer();

    if (checkAssert) assertEquals("Hook notifications", RUNS+1, counter);
  }


  //=====================================================

  /* ANGY

    // 3) INVOKEINTERFACE - call to empty weaver because of on active, unlocked joinpoint
    public void testInterfaceMethodRedefinition_LongO() {
      Object obj = new Object();

      obInterface.interfaceMethodLongO(obj, obj);

      startChronometer();
      for (int i = 0; i < RUNS; i++) obInterface.interfaceMethodLongO(obj, obj);
      stopChronometer();

      if (checkAssert) assertEquals("Hook notifications", RUNS+1, counter);
    }
   */

  //=====================================================

  // 3) INVOKESTATIC - call to empty weaver because of on active, unlocked joinpoint
  public void testStaticMethodRedefinition_LongO() {
    Object obj = new Object();

    JoinPointTestClass.staticMethodLongO(obj, obj);

    startChronometer();
    for (int i = 0; i < RUNS; i++) JoinPointTestClass.staticMethodLongO(obj, obj);
    stopChronometer();

    if (checkAssert) assertEquals("Hook notifications", RUNS+1, counter);
  }

  //=====================================================

  /* ANGY
    // 3) INVOKESPECIAL - call to empty weaver because of on active, unlocked joinpoint
    public void testSpecialMethodRedefinition_LongO() {
      Object obj = new Object();

      startChronometer();
      for (int i = 0; i < RUNS; i++) privatelocalMethodLongO(obj, obj);
      stopChronometer();

      if (checkAssert) assertEquals("Hook notifications", RUNS, counter);
    }   
   */   
  //=====================================================
  //=====================================================   

  public static Test suite() {
    return new PerformanceTestSuite(ProceedMeasurements1_micro_1_LongO_aj.class);
  }

}
TOP

Related Classes of measurements.suites.ProceedMeasurements1_micro_1_LongO_aj

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.