Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete tests in org.eclipse.core.tests.resources #525 #674

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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