HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: //opt/perf/examples/arm/jstartstop.java
//*******************************************************************
// /opt/perf/examples/arm/jstartstop.java
//
// A simple java program that performs arm_start and arm_stop in a loop.
// This program shows a simple example use of the Java bindings for ARM.
// It makes about 10 start/stop calls per second.
//
// Hewlett-Packard Performance Technology Center 04JAN01
//*******************************************************************

import armapi.*;

public class jstartstop {

  public static void main(String[] args) throws Exception
  {

    int j;

    ARMApplication armapp = new ARMApplication("Java_App", "*");

     // createTransaction method calls arm_getid
    ARMTransaction tran =
    armapp.createTransaction("jstartstop","jstartstop example transaction");

    ARMTransactionInstance traninstance = tran.createTransactionInstance();

    // loop forever doing sets of transactions
    while(true)
    	{
    	  // keep track of beginning time of this transaction set
    	  long start_time = System.currentTimeMillis();

      	  // 10 transactions in a set
      	  for ( j = 0; j < 10; j++)

      		 {
        		// startTran method calls arm_start
        		traninstance.startTran();

        		// this would normally be where the activity of the real transaction
        		// would occur...
        		DoWork();

        		// stopTranInstance calls arm_stop
        		traninstance.stopTranInstance(ARMConstants.ARM_GOOD);
      		 } // end of for loop

      	  // keep track of ending time for this transaction set
      	  long end_time = System.currentTimeMillis();
      	  long elapsed_time = end_time - start_time;
      	  System.out.println("Total time to perform " + j +
          " start and stop sets = " + (float) elapsed_time / 1000.0 +
          " seconds.");

      	  // sleep for a little less than 1 second before next transaction set
          Thread.sleep(860);

    	} // end of (endless) while loop

   } // end of main



  // In this example we just generate a random number
  public static void DoWork()
  {
    double f = Math.random() * 1000;
    int z;

    //an empty counter, so transactions will take long enough to show up in
    //glance plus.  To view, open glance and and click on reports, then click
    //on trasaction tracking.  A new window should open up, you can view the
    //time in the Wall Time/Tran column.  The time should be around 0.017
    //(time will vary depending on machine example is running on).
    for ( z = 0; z < 1000000; z++)
    {
    }

  } // end DoWork method

} // end of jstartstop class