@Override
  public void finish(TestCase testCase) {
    // Set relative compressed size (in percents) as resultX
    double sizeRatio = calcSizeRatio();

    testCase.setDoubleParam("japex.resultValueX", 100.0 * sizeRatio);
    getTestSuite().setParam("japex.resultUnitX", "Size%");

    // And main result throughput, MB/s

    //        testCase.setParam("japex.inputFile", _inputFile.getAbsolutePath());

    double itersPerSec =
        1000.0
            * testCase.getDoubleParam(Constants.RUN_ITERATIONS_SUM)
            / testCase.getDoubleParam(Constants.ACTUAL_RUN_TIME);
    double throughputMBps = itersPerSec * _uncompressed.length / (1024.0 * 1024.0);

    // truncate outliers (see javadocs for MAX values)
    double MAX;
    if (_operation == Operation.COMPRESS) {
      MAX = MAX_COMPRESS_THROUGHPUT;
    } else if (_operation == Operation.UNCOMPRESS) {
      MAX = MAX_UNCOMPRESS_THROUGHPUT;
    } else {
      MAX = MAX_BOTH_THROUGHPUT;
    }
    if (throughputMBps > MAX) {
      throughputMBps = MAX;
    }

    testCase.setDoubleParam("japex.resultValue", throughputMBps);
    testCase.setParam("japex.resultUnit", "MB/s");
  }
  @Override
  public void prepare(TestCase testCase) {
    String name = testCase.getName();

    String[] parts = name.split(":");
    if (parts.length < 2) {
      throw new IllegalArgumentException(
          "Invalid test name '" + name + "'; should have at least 2 components separated by slash");
    }
    _operation = null;
    String operStr = parts[0];
    String filename = parts[1];
    if (operStr.startsWith("C")) {
      _operation = Operation.COMPRESS;
    } else if (operStr.startsWith("U")) {
      _operation = Operation.UNCOMPRESS;
    } else if (operStr.startsWith("R")) {
      _operation = Operation.ROUNDTRIP;
    } else {
      throw new IllegalArgumentException(
          "Invalid 'operation' part of name, '" + operStr + "': should start with 'C', 'U' or 'R'");
    }
    _inputFile = new File(_inputDir, filename);
    try {
      // First things first: load uncompressed input in memory; compress to verify round-tripping
      _uncompressed = loadFile(_inputFile);
      _compressed = compressBlock(_uncompressed);
      verifyRoundTrip(testCase.getName(), _uncompressed, _compressed);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  @Override
  public void finish(TestCase testCase) {

    assertEquals(0, clearVM());
    if (testCase.getName().equals("test12")) {
      System.out.println("warmups: ");
      for (int j = 0; j < TN; j++)
        for (int i = 0; i < WC; i += 1) {
          System.out.println(warmups[j][i]);
        }
    }
  }
 @Override
 public void doPrepare(TestCase tc, JCRTestContext context) throws Exception {
   super.doPrepare(tc, context);
   container = StandaloneContainer.getInstance();
   registryService = (RegistryService) container.getComponentInstanceOfType(RegistryService.class);
   sessionProvider = new SessionProvider(ConversationState.getCurrent());
   // fill class field sumIterations with adequate number
   if ((tc.hasParam("japex.runIterations")) && (tc.getIntParam("japex.runIterations") > 0)) {
     sumIterations += tc.getIntParam("japex.runIterations");
   }
   if ((tc.hasParam("japex.warmupIterations")) && (tc.getIntParam("japex.warmupIterations") > 0)) {
     sumIterations += tc.getIntParam("japex.warmupIterations");
   }
   // create content. May be overridden in child class with stub method to
   // avoid any preparation.
   createContent(tc, context);
 }