uk.org.skeet.jbench.tasks
Class ReflectionTask

java.lang.Object
  |
  +--uk.org.skeet.jbench.tasks.SimpleTask
        |
        +--uk.org.skeet.jbench.tasks.ReflectionTask
All Implemented Interfaces:
BenchTask

public class ReflectionTask
extends SimpleTask

Class to test reflection speed. Currently only three types of test are supported: "normal" (no reflection), "invoke" (find the method beforehand, just invoke it within the loop), and "full" (find the method within the loop, once per invocation (ie twice per time round the loop)).

The arguments passed to Class.getMethod and Method.invoke are only created once in the reflection tests, to discover the overhead of just the reflection invocation itself - a fuller test may wish to go through the "pain" of creating these each time for a more realistic test of more usual application use.

The method invoked uses boxing/unboxing (int<->Integer) but has no return value - obviously these factors may also change the speed.


Constructor Summary
ReflectionTask()
           
 
Method Summary
 void checkConfiguration()
          Checks that we have a positive size
 void checkResults()
          Simple no-op implementation of checkResults.
 java.lang.String getDescription()
          Default description which gives the name of the actual class and the number of iterations.
 void incrementCounter(int amount)
          Increments the counter by the set amount
 void prepareTest()
          Simple no-op implementation of prepareTest.
 void runTest()
          Runs a test.
 void setType(java.lang.String type)
          Sets the type of test
 
Methods inherited from class uk.org.skeet.jbench.tasks.SimpleTask
getSize, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionTask

public ReflectionTask()
Method Detail

setType

public void setType(java.lang.String type)
Sets the type of test

runTest

public void runTest()
             throws TaskException
Description copied from interface: BenchTask
Runs a test. This is the method which is timed for result purposes. This should not include any preparation or result checking unless the time reported deliberately requires it.
See Also:
BenchTask.runTest()

checkConfiguration

public void checkConfiguration()
                        throws ConfigurationException
Description copied from class: SimpleTask
Checks that we have a positive size
Overrides:
checkConfiguration in class SimpleTask
See Also:
SimpleTask.checkConfiguration()

prepareTest

public void prepareTest()
                 throws TaskException
Description copied from class: SimpleTask
Simple no-op implementation of prepareTest.
Overrides:
prepareTest in class SimpleTask
See Also:
SimpleTask.prepareTest()

getDescription

public java.lang.String getDescription()
Description copied from class: SimpleTask
Default description which gives the name of the actual class and the number of iterations.
Overrides:
getDescription in class SimpleTask
See Also:
SimpleTask.getDescription()

incrementCounter

public void incrementCounter(int amount)
Increments the counter by the set amount

checkResults

public void checkResults()
                  throws TaskException
Description copied from class: SimpleTask
Simple no-op implementation of checkResults.
Overrides:
checkResults in class SimpleTask
See Also:
SimpleTask.checkResults()