FileDocCategorySizeDatePackage
Benchmark.javaAPI DocApache Lucene 2.2.03993Sat Jun 16 22:21:00 BST 2007org.apache.lucene.benchmark.byTask

Benchmark

public class Benchmark extends Object
Run the benchmark algorithm.

Usage: java Benchmark algorithm-file

  1. Read algorithm.
  2. Run the algorithm.
Things to be added/fixed in "Benchmarking by tasks":
  1. TODO - report into Excel and/or graphed view.
  2. TODO - perf comparison between Lucene releases over the years.
  3. TODO - perf report adequate to include in Lucene nightly build site? (so we can easily track performance changes.)
  4. TODO - add overall time control for repeated execution (vs. current by-count only).
  5. TODO - query maker that is based on index statistics.

Fields Summary
private PerfRunData
runData
private org.apache.lucene.benchmark.byTask.utils.Algorithm
algorithm
private boolean
executed
Constructors Summary
public Benchmark(Reader algReader)

    // prepare run data
    try {
      runData = new PerfRunData(new Config(algReader));
    } catch (Exception e) {
      e.printStackTrace();
      throw new Exception("Error: cannot init PerfRunData!",e);
    }
    
    // parse algorithm
    try {
      algorithm = new Algorithm(runData);
    } catch (Exception e) {
      throw new Exception("Error: cannot understand algorithm!",e);
    }
  
Methods Summary
public synchronized voidexecute()

    if (executed) {
      throw new IllegalStateException("Benchmark was already executed");
    }
    executed = true;
    algorithm.execute();
  
public org.apache.lucene.benchmark.byTask.utils.AlgorithmgetAlgorithm()

return
Returns the algorithm.

    return algorithm;
  
public PerfRunDatagetRunData()

return
Returns the runData.

    return runData;
  
public static voidmain(java.lang.String[] args)
Run the benchmark algorithm.

param
args benchmark config and algorithm files

    // verify command line args
    if (args.length < 1) {
      System.err.println("Usage: java Benchmark <algorithm file>");
      System.exit(1);
    }
    
    // verify input files 
    File algFile = new File(args[0]);
    if (!algFile.exists() || !algFile.isFile() || !algFile.canRead()) {
      System.err.println("cannot find/read algorithm file: "+algFile.getAbsolutePath()); 
      System.exit(1);
    }
    
    System.out.println("Running algorithm from: "+algFile.getAbsolutePath());
    
    Benchmark benchmark = null;
    try {
      benchmark = new Benchmark(new FileReader(algFile));
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }

    System.out.println("------------> algorithm:");
    System.out.println(benchmark.getAlgorithm().toString());

    // execute
    try {
      benchmark.execute();
    } catch (Exception e) {
      System.err.println("Error: cannot execute the algorithm! "+e.getMessage());
      e.printStackTrace();
    }

    System.out.println("####################");
    System.out.println("###  D O N E !!! ###");
    System.out.println("####################");