import java.io.IOException;

import org.basex.core.*;
import org.basex.core.cmd.*;
import org.basex.util.*;

public class ReplaceVsDelete {

  public static void main(String... args) throws IOException {
    int runs = 100000;

    Context ctx = new Context();
    new CreateDB("test").execute(ctx);
    new Set(MainOptions.INTPARSE, true).execute(ctx);
    new Set(MainOptions.AUTOFLUSH, false).execute(ctx);

    Performance perf = new Performance();

    for (int r = 0; r < runs; r++) {
      new Replace(r + ".xml", "<x>" + r + "</x>").execute(ctx);
    }
    System.out.println(perf);

    for (int r = runs - 1; r >= 0; r--) {
      new Delete(r + ".xml").execute(ctx);
    }
    System.out.println(perf);

    ctx.close();
  }
}
