/**
   * Save the actual configuration
   *
   * @param confToSave The configuration to save
   */
  static synchronized void saveConfiguration(PerformanceParameters confToSave)
      throws IOException, BackingStoreException {

    if (!loadConfiguration().getVMParameters().equals(confToSave.getVMParameters())) {
      confToSave.vmParameters.save();
    }

    Config configuration = EngineConfig.instance().load();
    Preferences preferences = configuration.preferences();

    Path cachePath = confToSave.getCachePath();

    if (!Files.exists(cachePath)) {
      Files.createDirectories(cachePath);
    }

    if (Files.exists(cachePath)) {
      preferences.put(
          SystemUtils.SNAP_CACHE_DIR_PROPERTY_NAME, cachePath.toAbsolutePath().toString());
    } else {
      SystemUtils.LOG.severe(
          "Directory for cache path does not exist and could not be created: "
              + cachePath.toAbsolutePath().toString());
    }

    preferences.putInt(PROPERTY_JAI_PARALLELISM, confToSave.getNbThreads());
    preferences.putInt(PROPERTY_DEFAULT_TILE_SIZE, confToSave.getDefaultTileSize());
    preferences.putInt(PROPERTY_JAI_CACHE_SIZE, confToSave.getCacheSize());
    JAI.getDefaultInstance().getTileCache().setMemoryCapacity(confToSave.getCacheSize());
    preferences.flush();
  }
  /**
   * Cloning constructor
   *
   * @param clone the performance parameter to copy
   */
  public PerformanceParameters(PerformanceParameters clone) {
    this.setVMParameters(clone.vmParameters.toString());
    this.setCachePath(clone.getCachePath());

    this.setNbThreads(clone.getNbThreads());
    this.setDefaultTileSize(clone.getDefaultTileSize());
    this.setCacheSize(clone.getCacheSize());
  }