/*
* PerformanceTest.java
* Copyright (C) 2007 Amin Ahmad.
*
* This file is part of Java Ropes.
*
* Java Ropes is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Java Ropes is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Java Ropes. If not, see .
*
* Amin Ahmad can be contacted at amin.ahmad@gmail.com or on the web at
* www.ahmadsoft.org.
*/
package org.ahmadsoft.ropes.test;
import java.io.BufferedReader;
import java.io.CharArrayWriter;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.ahmadsoft.ropes.Rope;
import org.ahmadsoft.ropes.impl.AbstractRope;
/**
* Performs an extensive performance test comparing Ropes, Strings, and
* StringBuffers.
* @author aahmad
*/
public class PerformanceTest {
private static int seed=342342;
private static Random random = new Random(PerformanceTest.seed);
private static int lenCC = 182029;
private static int lenBF = 467196;
private static final int ITERATION_COUNT = 7;
private static final int PLAN_LENGTH = 500;
private static String complexString=null;
private static StringBuffer complexStringBuffer=null;
private static Rope complexRope=null;
/**
* @param args
*/
public static void main(final String[] args) throws Exception {
if (args.length == 1) {
seed = Integer.parseInt(args[0]);
}
long x,y;
x=System.nanoTime();
final char[] aChristmasCarol_RAW = PerformanceTest.readCC();
final char[] bensAuto_RAW = PerformanceTest.readBF();
final String aChristmasCarol = new String(aChristmasCarol_RAW);
final String bensAuto = new String(bensAuto_RAW);
y=System.nanoTime();
System.out.println("Read " + aChristmasCarol.length() + " bytes in " + PerformanceTest.time(x,y));
System.out.println();
System.out.println("**** DELETE PLAN TEST ****");
System.out.println();
int newSize = PerformanceTest.lenCC;
final int[][] deletePlan=new int[PLAN_LENGTH][2];
for (int j=0;j> 1]: (stats[stats.length >> 1] + stats[1 + (stats.length >> 1)]) / 2);
double average = 0;
for (int j=1;j