/** * Tests the performance of MyersDiff for texts which are similar (not * random data). The CPU time is measured and returned. Because of bad * accuracy of CPU time information the diffs are repeated. During each * repetition the interim CPU time is checked. The diff operation is * repeated until we have seen the CPU time clock changed its value at least * {@link #minCPUTimerTicks} times. * * @param characters * the size of the diffed character sequences. * @return performance data */ private PerfData test(int characters) { PerfData ret = new PerfData(); string a = DiffTestDataGenerator.generateSequence(characters, 971, 3); string b = DiffTestDataGenerator.generateSequence(characters, 1621, 5); CharArray ac = new CharArray(a); CharArray bc = new CharArray(b); MyersDiff myersDiff = null; int cpuTimeChanges = 0; long lastReadout = 0; long interimTime = 0; int repetitions = 0; stopwatch.start(); while (cpuTimeChanges < minCPUTimerTicks && interimTime < longTaskBoundary) { myersDiff = new MyersDiff(ac, bc); repetitions++; interimTime = stopwatch.readout(); if (interimTime != lastReadout) { cpuTimeChanges++; lastReadout = interimTime; } } ret.runningTime = stopwatch.stop() / repetitions; ret.N = (ac.size() + bc.size()); ret.D = myersDiff.getEdits().size(); return(ret); }