Package jadex.benchmark
Class AbstractComponentBenchmark
java.lang.Object
jadex.benchmark.AbstractComponentBenchmark
Base class for testing component creation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final record
Struct to hold measurement data. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Collection
<jadex.core.ComponentIdentifier> Created components are stored for later killing.protected long
Timeout to cap test execution time (non-static so subclasses can alter it independently). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
createAndKillComponents
(int num, boolean print, boolean parallel) Called from runThroughputBenchmark() to create and immediately kill a number of components one at a time.protected abstract jadex.future.IFuture
<jadex.core.ComponentIdentifier> createComponent
(String name) Create a component with a given name.protected void
createComponents
(int num, boolean print, boolean parallel) Called from runCreationBenchmark() to create a number of components.protected void
gc()
Garbage collect as much as possible.protected String
Used in printing result.protected void
killComponents
(boolean print, boolean parallel) Called from runCreationBenchmark() to kill all created components.protected AbstractComponentBenchmark.Measurement
Run a piece of code and return time and mem measurement.protected void
printResults
(int num, AbstractComponentBenchmark.Measurement measurement) Print the results of a measurement.void
runCreationBenchmark
(int num, boolean print, boolean parallel) Create a number of agents and afterwards kill all agents.void
runThroughputBenchmark
(int num, boolean print, boolean parallel) Create and immediately kill one agent at a time for a given number of agents.
-
Field Details
-
TIMEOUT
protected long TIMEOUTTimeout to cap test execution time (non-static so subclasses can alter it independently). -
components
Created components are stored for later killing.
-
-
Constructor Details
-
AbstractComponentBenchmark
public AbstractComponentBenchmark()
-
-
Method Details
-
runCreationBenchmark
public void runCreationBenchmark(int num, boolean print, boolean parallel) Create a number of agents and afterwards kill all agents. Results are printed to System.out.- Parameters:
num
- How many components to create.print
- False: Only print overall results. True: Print additional creation/kill message for each component.parallel
- Use multiple threads to issue create and kill commands.
-
runThroughputBenchmark
public void runThroughputBenchmark(int num, boolean print, boolean parallel) Create and immediately kill one agent at a time for a given number of agents. Results are printed to System.out.- Parameters:
num
- How many components to create.print
- False: Only print overall results. True: Print additional creation/kill message for each component.parallel
- Use multiple threads to issue create and kill commands.
-
createComponents
protected void createComponents(int num, boolean print, boolean parallel) Called from runCreationBenchmark() to create a number of components. Created components should be stored in components field for later killing.- Parameters:
num
- How many components to create.print
- Print creation message for each component.parallel
- Use multiple threads to call createComponent() for different components
-
killComponents
protected void killComponents(boolean print, boolean parallel) Called from runCreationBenchmark() to kill all created components.- Parameters:
print
- Print kill message for each component.parallel
- Use multiple threads to call IComponent.terminate() for different components
-
createAndKillComponents
protected void createAndKillComponents(int num, boolean print, boolean parallel) Called from runThroughputBenchmark() to create and immediately kill a number of components one at a time.- Parameters:
num
- How many components to create.print
- Print creation/kill message for each component.parallel
- Use one thread for each logical CPU to measure multi-thread throughput.
-
createComponent
protected abstract jadex.future.IFuture<jadex.core.ComponentIdentifier> createComponent(String name) Create a component with a given name. -
getComponentTypeName
Used in printing result. Override to produce more specific output. -
measure
Run a piece of code and return time and mem measurement. -
gc
protected void gc()Garbage collect as much as possible. -
printResults
Print the results of a measurement.- Parameters:
num
- Number of components that were created/killed/etc.measurement
- Measured data.
-