Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ResourceSetTest.java

Go to the documentation of this file.
00001 /*
00002  * ResourceSetTest.java
00003  *
00004  * Copyright (c) 2003 The University of Utah and the Flux Group.
00005  * All rights reserved.
00006  *
00007  * This file is licensed under the terms of the GNU Public License.  
00008  * See the file "license.terms" for restrictions on redistribution 
00009  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  */
00011 
00012 /**
00013  * @file ResourceSetTest.java
00014  *
00015  * Test for the rk.ResourceSet class.
00016  */
00017 
00018 import rk.ResourceSet;
00019 
00020 /**
00021  * Test for the rk.ResourceSet class.
00022  */
00023 public class ResourceSetTest
00024 {
00025     /**
00026      * Volatile counter variable for an empty 'for' loop, otherwise, it might
00027      * get optimized away.
00028      */
00029     private static volatile int counter;
00030 
00031     /**
00032      * Verbosity flag, turned on when any arguments are passed to main.
00033      */
00034     public static boolean verbose;
00035 
00036     /**
00037      * Test for the rk.ResourceSet class.
00038      *
00039      * @param args The command line arguments.  If any are given, the test will
00040      * be more verbose about its activity.
00041      */
00042     public static void main(String args[])
00043     {
00044         long usage, usage2;
00045         
00046         if( args.length > 0 )
00047         {
00048             verbose = true;
00049         }
00050         
00051         /* Make sure its working in the first place. */
00052         usage = ResourceSet.getUsage();
00053         if( verbose )
00054         {
00055             System.out.println("usage = " + usage);
00056         }
00057         if( usage == 0 )
00058         {
00059             System.err.println("Zero usage?");
00060             System.exit(1);
00061         }
00062 
00063         /* Chew up some CPU and test again. */
00064         for( counter = 0; counter < 100000; counter += 1 );
00065         
00066         usage2 = ResourceSet.getUsage();
00067         if( verbose )
00068         {
00069             System.out.println("usage2 = " + usage2);
00070         }
00071         if( usage2 <= usage )
00072         {
00073             System.err.println("Bogus usage: old="
00074                                + usage
00075                                + "; new="
00076                                + usage2);
00077             System.exit(1);
00078         }
00079         
00080         System.exit(0);
00081     }
00082 }

Generated on Fri Oct 22 07:50:24 2004 for CPU Broker by  doxygen 1.3.9.1