Esempio n. 1
0
  private void doExecute(int startIndex, BatchCommand command, long startTime) {
    log.write(
        String.format(
            "      [Beginning " + startIndex + " of " + command.numberOfIterations() + ", '%s'] %s",
            command.shortDescription(),
            elapsedTime(startTime)));

    Transaction tx = db.beginTx();
    try {
      for (int index = startIndex; indexIsInRange(startIndex, command, index); index++) {
        command.execute(db, index, random);
        tx.success();
      }
    } finally {
      tx.finish();
    }
  }
Esempio n. 2
0
  public DomainEntityInfo execute(BatchCommand command) {
    long startTime = System.nanoTime();

    log.write(
        String.format(
            "Begin [%s Iterations: %s, BatchSize: %s]",
            command.description(), command.numberOfIterations(), command.batchSize()));
    command.onBegin(log);
    for (int index = 0; index < command.numberOfIterations(); index += command.batchSize()) {
      doExecute(index, command, startTime);
    }
    command.onEnd(log);
    log.write(String.format("End   [%s] %s\n", command.description(), elapsedTime(startTime)));

    return command.results();
  }
Esempio n. 3
0
 private static boolean indexIsInRange(int startIndex, BatchCommand command, int index) {
   return index < (startIndex + command.batchSize()) && index < command.numberOfIterations();
 }