コード例 #1
0
ファイル: Workload.java プロジェクト: rzs840707/mile
  /**
   * Initialize the workload. Called once, in the main client thread, before any operations are
   * started.
   *
   * @throws IOException
   * @throws ClassNotFoundException
   */
  public void init(Props props) throws IOException {
    CmdProvider cmdProvider;
    int readPercent = props.getInt(Benchmark.SELECT, 0);
    int writePercent = props.getInt(Benchmark.INSERT, 0);

    double readProportion = (double) readPercent / (double) 100;
    double writeProportion = (double) writePercent / (double) 100;

    if (readProportion + writeProportion > 0) {
      double sum = readProportion + writeProportion;
      readProportion = readProportion / sum;
      writeProportion = writeProportion / sum;
    }

    if (readProportion > 0) {
      cmdProvider = new QueryProvider(props);
      operationChooser.addValue(readProportion, cmdProvider.getName());
      operations.put(cmdProvider.getName(), cmdProvider);
    }
    if (writeProportion > 0) {
      cmdProvider = new InsertProvider(props);
      operationChooser.addValue(writeProportion, cmdProvider.getName());
      operations.put(cmdProvider.getName(), cmdProvider);
    }
    if (props.containsKey(Benchmark.RECORD_FILE)) {
      String cmd = props.getString(Benchmark.CMD_PROVIDER, "");
      if (StringUtils.startsWith(cmd, "ctu_minisearch")) {
        cmdProvider = new CtuMiniSearchProvider(props);
      } else {
        cmdProvider = new SqlFileProvider(props);
      }
      operationChooser.addValue(1.0, cmdProvider.getName());
      operations.put(cmdProvider.getName(), cmdProvider);
    }
  }
コード例 #2
0
ファイル: Benchmark.java プロジェクト: rzs840707/mile
  public void initializeWorkload(Props workloadProps) throws MileException, IOException {

    if (!this.storeInitialized) {
      throw new MileException("Store not initialized correctly");
    }

    // Calculate perThreadThroughputPerMs = default unlimited (-1)
    this.targetThroughput = workloadProps.getInt(TARGET_THROUGHPUT, -1);
    this.perThreadThroughputPerMs = -1;
    if (targetThroughput > 0) {
      double targetperthread = ((double) targetThroughput) / ((double) numThreads);
      this.perThreadThroughputPerMs = targetperthread / 1000.0;
    }

    // Compulsory parameters
    if (workloadProps.containsKey(OPS_COUNT)) {
      this.opsCount = workloadProps.getInt(OPS_COUNT);
    } else {
      throw new MileException("Missing compulsory parameters - " + OPS_COUNT);
    }

    // Initialize measurement
    Metrics.setProperties(workloadProps);
    Metrics.getInstance().reset();

    // Initialize workload
    this.workLoad = new Workload();
    this.workLoad.init(workloadProps);
  }