//
/**
* Class RandNum
*
* Provides random numbers based on the second-order linear
* congruential generator that we've always used. Initialization
* constants are suggested by J. G. Skellam.
*/
final class RandNum
{
// The current value of the random number generator.
int [] currval;
/**
* constructor **
*/
// The constructor merely initializes the current value.
public RandNum()
{
currval = new int[2]; // Allocate array.
currval[0] = 13;
currval[1] = 117;
}
/**
* next
*
* Returns the next random number in the sequence.
*/
public int next()
{
int temp; // Holds intermediate calculations.
temp = (currval[0] * 254754 + currval[1] * 529562) % 999563;
currval[1] = currval[0];
currval[0] = temp;
return (temp);
}
/**
* nextwc
*
* Returns next random number, but with a ceiling.
*/
public int nextwc(int ceiling)
{
return(next() % ceiling);
}
/**
* abs_nextwc
*
* Returns next random number with ceiling; applies absolute value
* function on the way out.
*/
public int abs_nextwc(int ceiling)
{
int temp;
temp = nextwc(ceiling);
return (Math.abs(temp));
}
}
//
final class testclass
{
byte[] bytes;
public testclass(int n)
{
bytes = new byte[n];
bench.allocated++;
}
protected void finalize() throws Throwable
{
//System.out.println("finalized");
bytes = null;
bench.allocated--;
super.finalize();
}
}
//
final class testclass1
{
public final int func(int t)
{
t=t+1;
return(t);
}
}
//
class testclassr
{
public int func(int t)
{
t=t+2;
return(t);
}
}
class testclass2 extends testclassr //;-)
{
public int func(int t)
{
t=t+1;
return(t);
}
}
final class bench
{
static int allocated;
public static void main (String args[])
{
int N=2500;
int N2=10000000;
int i,k;
int r;
long time,total_time;
int which;
RandNum rndnum = new RandNum();
testclass[] test = new testclass[N];
Runtime RT = Runtime.getRuntime();
testclassr tt0;
testclass1 tt1;
testclass2 tt2;
time = System.currentTimeMillis();
//
allocated=0;
for(k=0;k<1;k++)
{
//System.out.println("free/total: "+RT.freeMemory()+"/"+RT.totalMemory());
for(i=0;i
total_time=0;
for(k=0;k<10;k++)
{
time = System.currentTimeMillis();
for(i=0;i
r=0;
tt0 = new testclassr();
time = System.currentTimeMillis();
for(i=0;i