public class BenchmarkRunner {
private static final int MB = 1024 * 1024;
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
OptionSpec<File> base = parser.accepts("base", "Base directory")
.withRequiredArg().ofType(File.class)
.defaultsTo(new File("target"));
OptionSpec<String> host = parser.accepts("host", "MongoDB host")
.withRequiredArg().defaultsTo("localhost");
OptionSpec<Integer> port = parser.accepts("port", "MongoDB port")
.withRequiredArg().ofType(Integer.class).defaultsTo(27017);
OptionSpec<String> dbName = parser.accepts("db", "MongoDB database")
.withRequiredArg();
OptionSpec<Boolean> dropDBAfterTest = parser.accepts("dropDBAfterTest", "Whether to drop the MongoDB database after the test")
.withOptionalArg().ofType(Boolean.class).defaultsTo(true);
OptionSpec<Boolean> mmap = parser.accepts("mmap", "TarMK memory mapping")
.withOptionalArg().ofType(Boolean.class)
.defaultsTo("64".equals(System.getProperty("sun.arch.data.model")));
OptionSpec<Integer> cache = parser.accepts("cache", "cache size (MB)")
.withRequiredArg().ofType(Integer.class).defaultsTo(100);
OptionSpec<File> wikipedia =
parser.accepts("wikipedia", "Wikipedia dump")
.withRequiredArg().ofType(File.class);
OptionSpec<Boolean> runAsAdmin = parser.accepts("runAsAdmin", "Run test using admin session")
.withRequiredArg().ofType(Boolean.class).defaultsTo(Boolean.FALSE);
OptionSpec<Integer> itemsToRead = parser.accepts("itemsToRead", "Number of items to read")
.withRequiredArg().ofType(Integer.class).defaultsTo(1000);
OptionSpec<Integer> concurrency = parser.accepts("concurrency", "Number of test threads.")
.withRequiredArg().ofType(Integer.class).withValuesSeparatedBy(',');
OptionSpec<Boolean> report = parser.accepts("report", "Whether to output intermediate results")
.withOptionalArg().ofType(Boolean.class)
.defaultsTo(Boolean.FALSE);
OptionSpec<Boolean> randomUser = parser.accepts("randomUser", "Whether to use a random user to read.")
.withOptionalArg().ofType(Boolean.class)
.defaultsTo(Boolean.FALSE);
OptionSpec<File> csvFile = parser.accepts("csvFile", "File to write a CSV version of the benchmark data.")
.withOptionalArg().ofType(File.class);
OptionSet options = parser.parse(args);
int cacheSize = cache.value(options);
RepositoryFixture[] allFixtures = new RepositoryFixture[] {
new JackrabbitRepositoryFixture(
base.value(options), cacheSize),
OakRepositoryFixture.getMemory(cacheSize * MB),