Class AbstractComponentBenchmark

java.lang.Object
jadex.benchmark.AbstractComponentBenchmark

public abstract class AbstractComponentBenchmark extends Object
Base class for testing component creation.
  • Field Details

    • TIMEOUT

      protected long TIMEOUT
      Timeout to cap test execution time (non-static so subclasses can alter it independently).
    • components

      protected Collection<jadex.core.ComponentIdentifier> 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

      protected String getComponentTypeName()
      Used in printing result. Override to produce more specific output.
    • measure

      protected AbstractComponentBenchmark.Measurement measure(String name, Runnable benchmark)
      Run a piece of code and return time and mem measurement.
    • gc

      protected void gc()
      Garbage collect as much as possible.
    • printResults

      protected void printResults(int num, AbstractComponentBenchmark.Measurement measurement)
      Print the results of a measurement.
      Parameters:
      num - Number of components that were created/killed/etc.
      measurement - Measured data.