Crossfire JXClient, Trunk
Classes | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MergeDemo Class Reference
Collaboration diagram for MergeDemo:
Collaboration graph

Classes

class  Configuration
 
class  Range
 

Static Public Member Functions

static void main (String[] args)
 

Private Member Functions

int[] generateArray (int elements)
 
long medianValue (long[] times)
 
void printResults (Range sizes, Range parallelism, long[][] times)
 
void run (Configuration config)
 
long runForParallelism (int iterations, int elements, int parallelism)
 
void runForSize (Range parallelism, int elements, long[][] times, int size)
 
void warmup ()
 

Private Attributes

final Random random = new Random(759123751834L)
 

Static Private Attributes

static final int ITERATIONS = 10
 

Detailed Description

MergeExample is a class that runs a demo benchmark of the

ForkJoin

framework by benchmarking a MergeSort algorithm that is implemented using java.util.concurrent.RecursiveAction. The

ForkJoin

framework is setup with different parallelism levels and the sort is executed with arrays of different sizes to see the trade offs by using multiple threads for different sizes of the array.

Definition at line 54 of file MergeDemo.java.

Member Function Documentation

◆ generateArray()

int [] MergeDemo.generateArray ( int  elements)
private

Generates an array of

elements

random elements

Parameters
elementsthe number of elements requested in the array
Returns
an array of
elements
random elements

Definition at line 172 of file MergeDemo.java.

References random.

Referenced by runForParallelism(), and warmup().

Here is the caller graph for this function:

◆ main()

static void MergeDemo.main ( String[]  args)
static

Definition at line 288 of file MergeDemo.java.

References MergeDemo.Configuration.parse(), and run().

Here is the call graph for this function:

◆ medianValue()

long MergeDemo.medianValue ( long[]  times)
private

Calculates the median value of the array

Parameters
timesarray of times
Returns
the median value

Definition at line 265 of file MergeDemo.java.

Referenced by runForParallelism().

Here is the caller graph for this function:

◆ printResults()

void MergeDemo.printResults ( Range  sizes,
Range  parallelism,
long  times[][] 
)
private

Prints the results as a table

Parameters
sizesthe different sizes of the arrays
parallelismthe different parallelism levels used
timesthe median times for the different sizes / parallelism

Definition at line 207 of file MergeDemo.java.

References MergeDemo.Range.get(), MergeDemo.Range.getIterations(), and size.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

void MergeDemo.run ( Configuration  config)
private

Runs the test

Parameters
configcontains the settings for the test

Definition at line 184 of file MergeDemo.java.

References MergeDemo.Configuration.createTimesArray(), MergeDemo.Range.get(), MergeDemo.Range.getIterations(), MergeDemo.Configuration.parallelism, printResults(), runForSize(), size, MergeDemo.Configuration.sizes, and warmup().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runForParallelism()

long MergeDemo.runForParallelism ( int  iterations,
int  elements,
int  parallelism 
)
private

Runs iterations number of test sorts of a random array of element length

Parameters
iterationsnumber of iterations
elementsnumber of elements in the random array
parallelismparallelism for the ForkJoin framework
Returns
the median time of runs

Definition at line 244 of file MergeDemo.java.

References generateArray(), medianValue(), and MergeSort.sort().

Referenced by runForSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runForSize()

void MergeDemo.runForSize ( Range  parallelism,
int  elements,
long  times[][],
int  size 
)
private

Definition at line 230 of file MergeDemo.java.

References MergeDemo.Range.get(), MergeDemo.Range.getIterations(), ITERATIONS, runForParallelism(), size, and time.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ warmup()

void MergeDemo.warmup ( )
private

Generates 1000 arrays of 1000 elements and sorts them as a warmup

Definition at line 281 of file MergeDemo.java.

References generateArray(), and MergeSort.sort().

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ITERATIONS

final int MergeDemo.ITERATIONS = 10
staticprivate

Definition at line 57 of file MergeDemo.java.

Referenced by runForSize().

◆ random

final Random MergeDemo.random = new Random(759123751834L)
private

Definition at line 56 of file MergeDemo.java.

Referenced by generateArray().


The documentation for this class was generated from the following file: