Skip to content

Commit

Permalink
Delete tests in org.eclipse.core.tests.resources eclipse-platform#525
Browse files Browse the repository at this point in the history
In this commit, the deactivated performance tests "_testPerformanceManyResources()"  and "_testPerformanceOneResource()" from MarkerTest.java in org.eclipse.core.tests.resources are deleted because they are not real test methods but rather used for code measuring and printing the time for processing operations on markers. See also eclipse-platform#605 (comment). Contributes to eclipse-platform#525
  • Loading branch information
Michael5601 authored and fedejeanne committed Sep 13, 2023
1 parent 08ecfca commit 156b643
Showing 1 changed file with 0 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
Expand Down Expand Up @@ -151,159 +150,6 @@ private void addResourceChangeListener(MarkersChangeListener listener) {
}
}

public void _testPerformanceManyResources() {
debug("testPerformanceManyResources");
long start;
long stop;

// cleanup old resources and create our own
IResource[] testResources = null;
try {
getWorkspace().getRoot().delete(false, getMonitor());
testResources = createLargeHierarchy();
} catch (CoreException e) {
fail("0.0", e);
}

// header info
final int markersPerResource = 20;
final int numMarkers = testResources.length * markersPerResource;
display("\nNumber of resources: " + testResources.length);
display("Markers per resource: " + markersPerResource);
display("Total Number of Markers: " + numMarkers);

// Create an array with a bunch of markers.
IWorkspaceRunnable body = monitor -> {
IResourceVisitor visitor = resource -> {
for (int i = 0; i < markersPerResource; i++) {
resource.createMarker(IMarker.PROBLEM);
}
return true;
};
getWorkspace().getRoot().accept(visitor);
};
try {
start = System.currentTimeMillis();
getWorkspace().run(body, getMonitor());
stop = System.currentTimeMillis();
display("Task: creating markers");
display(start, stop);
} catch (CoreException e) {
fail("0.0", e);
}

// gather the markers for use. don't time this one.
final IMarker[] markers = new IMarker[numMarkers];
try {
IMarker[] temp = getWorkspace().getRoot().findMarkers(null, true, IResource.DEPTH_INFINITE);
assertEquals("0.1", numMarkers, temp.length);
System.arraycopy(temp, 0, markers, 0, temp.length);
} catch (CoreException e) {
fail("0.2", e);
}

// create attributes on each marker
body = monitor -> {
for (IMarker marker : markers) {
marker.setAttribute(IMarker.MESSAGE, getRandomString());
}
};
try {
start = System.currentTimeMillis();
getWorkspace().run(body, getMonitor());
stop = System.currentTimeMillis();
display("Task: setting an attribute on each marker");
display(start, stop);
} catch (CoreException e) {
fail("1.0", e);
}

// get the attribute from each marker
body = monitor -> {
for (IMarker marker : markers) {
marker.getAttribute(IMarker.MESSAGE);
}
};
try {
start = System.currentTimeMillis();
getWorkspace().run(body, getMonitor());
stop = System.currentTimeMillis();
display("Task: getting an attribute on each marker");
display(start, stop);
} catch (CoreException e) {
fail("2.0", e);
}
}

public void _testPerformanceOneResource() {
debug("testPerformanceOneResource");
long start;
long stop;
final int numMarkers = 4000;

// header info
display("Number of resources: 1");
display("Number of Markers: " + numMarkers);

// Create an array with a bunch of markers.
final IMarker markers[] = new IMarker[numMarkers];
IWorkspaceRunnable body = monitor -> {
IResource resource = getWorkspace().getRoot();
for (int i = 0; i < markers.length; i++) {
markers[i] = resource.createMarker(IMarker.PROBLEM);
}
};
try {
start = System.currentTimeMillis();
getWorkspace().run(body, getMonitor());
stop = System.currentTimeMillis();
display("Task: creating markers");
display(start, stop);
} catch (CoreException e) {
fail("0.0", e);
}

// create attributes on each marker
body = monitor -> {
for (IMarker marker : markers) {
marker.setAttribute(IMarker.MESSAGE, getRandomString());
}
};
try {
start = System.currentTimeMillis();
getWorkspace().run(body, getMonitor());
stop = System.currentTimeMillis();
display("Task: setting an attribute on each marker");
display(start, stop);
} catch (CoreException e) {
fail("1.0", e);
}

java.util.Comparator<IMarker> c = (o1, o2) -> {
try {
String name1 = (String) o1.getAttribute(IMarker.MESSAGE);
String name2 = (String) o2.getAttribute(IMarker.MESSAGE);
if (name1 == null) {
name1 = "";
}
if (name2 == null) {
name2 = "";
}
int result = name1.compareToIgnoreCase(name2);
return result;
} catch (CoreException e) {
fail("2.0", e);
}
// avoid compiler error
return -1;
};
start = System.currentTimeMillis();
Arrays.sort(markers, c);
stop = System.currentTimeMillis();
display("Task: sort arrays based on MESSAGE attribute");
display(start, stop);
}

protected void addChildren(ArrayList<String> result, IPath root, int breadth, int depth) {
for (int i = 1; i < breadth + 1; i++) {
IPath child = root.append(i + "");
Expand Down

0 comments on commit 156b643

Please sign in to comment.