Class CBackend


public class CBackend extends BenchmarkBackend
Compiles benchmarks to C, then compiles C code to an executable and runs it. Every fork runs in a separate process.
  • Constructor Details

  • Method Details

    • setCompiler

      public void setCompiler(String compiler)
    • setCompilerFlags

      public void setCompilerFlags(List<String> compilerFlags)
    • setBuildScript

      public void setBuildScript(File buildScript)
      Sets script that is used to compile C code instead of invoking C compiler directly. The script runs in the directory with generated C code and must produce benchmark executable (benchmark.exe on Windows) in the same directory.
    • setEnvScript

      public void setEnvScript(File envScript)
      Sets script that prepares environment for C compiler (for example, sets up MSVC developer environment). The script runs once, then the environment it produces is used for every compiler invocation.
    • getName

      public String getName()
      Description copied from class: BenchmarkBackend
      Short identifier of the backend, also used in command line.
      Specified by:
      getName in class BenchmarkBackend
    • getDescription

      public String getDescription()
      Description copied from class: BenchmarkBackend
      Human-readable description, used in reports. Mapped to vmName field of JMH JSON output.
      Specified by:
      getDescription in class BenchmarkBackend
    • compile

      public CompiledBenchmark compile(BenchmarkInfo benchmark, File directory) throws BenchmarkException
      Specified by:
      compile in class BenchmarkBackend
      Throws:
      BenchmarkException
    • run

      public void run(CompiledBenchmark benchmark, String argument, Consumer<String> outputConsumer) throws BenchmarkException
      Description copied from class: BenchmarkBackend
      Runs compiled benchmark once, i.e. performs a single JMH fork.
      Specified by:
      run in class BenchmarkBackend
      Parameters:
      outputConsumer - receives every line written by benchmark to stdout.
      Throws:
      BenchmarkException