public abstract class Benchmark
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected Config |
config
Parsed version of the configuration file for this benchmark
|
protected int |
iteration
Keep track of the number of times we have been iterated.
|
protected java.lang.ClassLoader |
loader
Classloader used to run the benchmark
|
protected java.lang.reflect.Method |
method |
protected java.io.File |
scratch
The scratch directory
|
| Constructor and Description |
|---|
Benchmark(Config config,
java.io.File scratch)
When an instance of a Benchmark is created, it is expected to prepare its
scratch directory, unloading files from the jar file if required.
|
Benchmark(Config config,
java.io.File scratch,
boolean silent) |
| Modifier and Type | Method and Description |
|---|---|
void |
augmentSystemProperties(java.util.Properties systemProperties)
Augments the system properties in case additional properties need to be in
effect during the actual benchmark iteration.
|
static long |
byteCount(java.io.File file) |
void |
cleanup()
Perform post-benchmark cleanup, deleting output files etc.
|
static void |
deleteFile(java.io.File file) |
static void |
deleteTree(java.io.File tree) |
static void |
extractFileResource(java.lang.String name,
java.io.File destination) |
java.lang.String |
fileInScratch(java.lang.String name)
Return a file name, relative to the specified scratch directory.
|
protected int |
getIteration() |
static boolean |
getPreserve() |
static boolean |
getSilent() |
static java.net.URL |
getURL(java.lang.String fn)
Translate a resource name into a URL.
|
static boolean |
getValidate() |
static boolean |
getValidateOutput() |
static boolean |
getVerbose() |
abstract void |
iterate(java.lang.String size)
An actual iteration of the benchmark.
|
static int |
lineCount(java.io.File file) |
void |
postIteration(java.lang.String size)
Per-iteration cleanup, outside the timing loop.
|
protected void |
postIterationCleanup(java.lang.String size)
Perform post-iteration cleanup.
|
void |
preIteration(java.lang.String size)
Benchmark-specific per-iteration setup, outside the timing loop.
|
protected void |
prepare()
Perform pre-benchmark preparation.
|
protected void |
prepare(java.lang.String size)
One-off preparation performed once we know the benchmark size.
|
protected void |
revertClassLoader()
TODO
|
boolean |
run(Callback callback,
java.lang.String size)
Run a benchmark.
|
static void |
setCommandLineOptions(CommandLineArgs line) |
void |
startIteration()
Per-iteration setup, inside the timing loop.
|
void |
stopIteration()
Post-iteration tear-down, inside the timing loop.
|
static void |
unpackZipFileResource(java.lang.String name,
java.io.File destination)
Unpack a zip file resource into the specified directory.
|
protected void |
useBenchmarkClassLoader()
TODO
|
boolean |
validate(java.lang.String size)
Perform validation of output.
|
protected final java.io.File scratch
protected final Config config
protected java.lang.ClassLoader loader
protected int iteration
protected java.lang.reflect.Method method
public Benchmark(Config config, java.io.File scratch) throws java.lang.Exception
scratch - Scratch directoryjava.lang.Exceptionpublic Benchmark(Config config, java.io.File scratch, boolean silent) throws java.lang.Exception
java.lang.Exceptionpublic final boolean run(Callback callback, java.lang.String size) throws java.lang.Exception
callback - The user-specified timing callbacksize - The size (as given on the command line)java.lang.Exception - Whatever exception the target application dies withprotected void prepare()
throws java.lang.Exception
data/name.zip into the scratch directory.java.lang.Exceptionprotected void prepare(java.lang.String size)
throws java.lang.Exception
size - The size (as defined in the per-benchmark configuration file).java.lang.Exceptionpublic void preIteration(java.lang.String size)
throws java.lang.Exception
size - Size as specified by the "-s" command line flagjava.lang.Exceptionpublic final void startIteration()
public void augmentSystemProperties(java.util.Properties systemProperties)
systemProperties - the system properties that need to be augmented.
(They may be modified freely.)public abstract void iterate(java.lang.String size)
throws java.lang.Exception
size - Argument to the benchmark iteration.java.lang.Exceptionpublic final void stopIteration()
protected void useBenchmarkClassLoader()
protected void revertClassLoader()
public boolean validate(java.lang.String size)
size - Size of the benchmark run.public void postIteration(java.lang.String size)
throws java.lang.Exception
size - Argument to the benchmark iteration.java.lang.Exceptionprotected void postIterationCleanup(java.lang.String size)
size - Argument to the benchmark iteration.public void cleanup()
public static java.net.URL getURL(java.lang.String fn)
fn - public java.lang.String fileInScratch(java.lang.String name)
name - Name of the file, relative to the top of the scratch directorypublic static void unpackZipFileResource(java.lang.String name,
java.io.File destination)
throws java.io.IOException,
java.io.FileNotFoundException,
DacapoException
name - destination - java.io.IOExceptionjava.io.FileNotFoundExceptionDacapoExceptionpublic static void extractFileResource(java.lang.String name,
java.io.File destination)
throws java.io.IOException,
java.io.FileNotFoundException,
DacapoException
java.io.IOExceptionjava.io.FileNotFoundExceptionDacapoExceptionpublic static void deleteTree(java.io.File tree)
public static void deleteFile(java.io.File file)
public static int lineCount(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static long byteCount(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static void setCommandLineOptions(CommandLineArgs line)
public static boolean getVerbose()
public static boolean getValidateOutput()
public static boolean getValidate()
public static boolean getPreserve()
protected int getIteration()
public static boolean getSilent()