Package measurements.suites

Source Code of measurements.suites.ProceedMeasurements1_micro_1_noArgs_aj

// $Id: ProceedMeasurements1_micro_1_noArgs_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_noArgs_aj extends PerformanceTest {
//public class ProceedMeasurements1_micro_1_noArgs_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_noArgs_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() { }

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

  // 3) INVOKEVIRTUAL - call to empty weaver because of on active, unlocked joinpoint
  public void testVirtualMethodRedefinition_NoArg() {
    localMethod();

    startChronometer();
    for (int i = 0; i < RUNS; i++) localMethod();
    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_NoArg() {
    obSync.syncMethodShort();

    startChronometer();
    for (int i = 0; i < RUNS; i++) obSync.syncMethodShort();
    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_NoArg() {
      obInterface.interfaceMethodShort();

      startChronometer();
      for (int i = 0; i < RUNS; i++) obInterface.interfaceMethodShort();
      stopChronometer();

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

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

  // 3) INVOKESTATIC - call to empty weaver because of on active, unlocked joinpoint
  public void testStaticMethodRedefinition_NoArg() {
    JoinPointTestClass.staticMethodShort();

    startChronometer();
    for (int i = 0; i < RUNS; i++) JoinPointTestClass.staticMethodShort();
    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_NoArg() {
  privatelocalMethod();

      startChronometer();
      for (int i = 0; i < RUNS; i++) privatelocalMethod();
      stopChronometer();

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

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

}
TOP

Related Classes of measurements.suites.ProceedMeasurements1_micro_1_noArgs_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.