Skip to content
Merged
Show file tree
Hide file tree
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 @@ -19,18 +19,20 @@
import java.util.Comparator;

import org.eclipse.jface.util.Policy;
import org.eclipse.test.performance.PerformanceTestCaseJunit4;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.eclipse.ui.tests.performance.UIPerformanceTestRule;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;

/**
* @since 3.5
*/
public class CollatorPerformanceTest extends PerformanceTestCaseJunit4 {
public class CollatorPerformanceTest {

@ClassRule
public static final UIPerformanceTestRule uiPerformanceTestRule = new UIPerformanceTestRule();
@RegisterExtension
static UIPerformanceTestRule uiPerformanceTestRule = new UIPerformanceTestRule();

private static final int ARRAYSIZE=100000;
private static String[] fArray;
Expand All @@ -43,16 +45,24 @@ public CollatorPerformanceTest() {
* test Collator by sorting the array
*/
@Test
public void testCollator(){
public void testCollator(TestInfo testInfo) {
Performance perf = Performance.getDefault();
String scenarioId = this.getClass().getName() + "." + testInfo.getDisplayName();
PerformanceMeter meter = perf.createPerformanceMeter(scenarioId);

Comparator<Object> comparator=Policy.getComparator();
for (int i = 0; i < 15; i++) {
String[] array=fArray.clone();
startMeasuring();
Arrays.sort(array, comparator);
stopMeasuring();
try {
for (int i = 0; i < 15; i++) {
String[] array=fArray.clone();
meter.start();
Arrays.sort(array, comparator);
meter.stop();
}
meter.commit();
perf.assertPerformance(meter);
} finally {
meter.dispose();
}
commitMeasurements();
assertPerformance();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,71 +26,81 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.test.performance.PerformanceTestCaseJunit4;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
import org.junit.Rule;
import org.junit.Test;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

/**
* ComboViewerRefreshTest is a test of refreshes of difference size in the combo
* viewer.
*/
public class FileImageDescriptorTest extends PerformanceTestCaseJunit4 {
public class FileImageDescriptorTest {

@Rule
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
@RegisterExtension
CloseTestWindowsExtension closeTestWindows = new CloseTestWindowsExtension();

protected static final String IMAGES_DIRECTORY = "/icons/imagetests";

/**
* Test the time for doing a refresh.
*/
@Test
public void testRefresh() throws Throwable {
public void testRefresh(TestInfo testInfo) throws Throwable {

exercise(() -> {
Class<?> missing = null;
ArrayList<Image> images = new ArrayList<>();
Performance perf = Performance.getDefault();
String scenarioId = this.getClass().getName() + "." + testInfo.getDisplayName();
PerformanceMeter meter = perf.createPerformanceMeter(scenarioId);

Bundle bundle = FrameworkUtil.getBundle(getClass());
Enumeration<String> bundleEntries = bundle.getEntryPaths(IMAGES_DIRECTORY);
try {
exercise(() -> {
Class<?> missing = null;
ArrayList<Image> images = new ArrayList<>();

Bundle bundle = FrameworkUtil.getBundle(getClass());
Enumeration<String> bundleEntries = bundle.getEntryPaths(IMAGES_DIRECTORY);

while (bundleEntries.hasMoreElements()) {
ImageDescriptor descriptor;
String localImagePath = bundleEntries.nextElement();

if (localImagePath.indexOf('.') < 0)
continue;
while (bundleEntries.hasMoreElements()) {
ImageDescriptor descriptor;
String localImagePath = bundleEntries.nextElement();

URL[] files = FileLocator.findEntries(bundle, IPath.fromOSString(localImagePath));
if (localImagePath.indexOf('.') < 0)
continue;

for (URL file : files) {
startMeasuring();
descriptor = ImageDescriptor.createFromFile(missing, FileLocator.toFileURL(file).getFile());
URL[] files = FileLocator.findEntries(bundle, IPath.fromOSString(localImagePath));

for (int j = 0; j < 10; j++) {
Image image = descriptor.createImage();
images.add(image);
}
for (URL file : files) {
meter.start();
descriptor = ImageDescriptor.createFromFile(missing, FileLocator.toFileURL(file).getFile());

processEvents();
stopMeasuring();
for (int j = 0; j < 10; j++) {
Image image = descriptor.createImage();
images.add(image);
}

}
processEvents();
meter.stop();

}

}
}


Iterator<Image> imageIterator = images.iterator();
while (imageIterator.hasNext()) {
imageIterator.next().dispose();
}
}, 20, 100, JFacePerformanceSuite.MAX_TIME);
Iterator<Image> imageIterator = images.iterator();
while (imageIterator.hasNext()) {
imageIterator.next().dispose();
}
}, 20, 100, JFacePerformanceSuite.MAX_TIME);

commitMeasurements();
assertPerformance();
meter.commit();
perf.assertPerformance(meter);
} finally {
meter.dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.test.performance.PerformanceTestCaseJunit4;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
import org.junit.Rule;
import org.junit.Test;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;

/**
* The ListPopulationTest is the test for simple
* SWT lists.
*/
public class ListPopulationTest extends PerformanceTestCaseJunit4 {
public class ListPopulationTest {

@Rule
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
@RegisterExtension
CloseTestWindowsExtension closeTestWindows = new CloseTestWindowsExtension();

List list;

Expand All @@ -52,72 +54,89 @@ protected void openBrowser() {
}

@Test
public void testSmallAdd() throws Throwable {
addBench(100);
public void testSmallAdd(TestInfo testInfo) throws Throwable {
addBench(100, testInfo);
}

@Test
public void testSmallSetItems() throws Throwable {
setItemsBench(100);
public void testSmallSetItems(TestInfo testInfo) throws Throwable {
setItemsBench(100, testInfo);
}

@Test
public void testMediumAdd() throws Throwable {
addBench(5000);
public void testMediumAdd(TestInfo testInfo) throws Throwable {
addBench(5000, testInfo);
}

@Test
public void testMediumSetItems() throws Throwable {
setItemsBench(5000);
public void testMediumSetItems(TestInfo testInfo) throws Throwable {
setItemsBench(5000, testInfo);
}

@Test
public void testLargeAdd() throws Throwable {
addBench(50000);
public void testLargeAdd(TestInfo testInfo) throws Throwable {
addBench(50000, testInfo);
}

@Test
public void testLargeSetItems() throws Throwable {
setItemsBench(50000);
public void testLargeSetItems(TestInfo testInfo) throws Throwable {
setItemsBench(50000, testInfo);
}

/**
* Test the time for adding elements using add.
*/
public void addBench(int count) throws Throwable {
public void addBench(int count, TestInfo testInfo) throws Throwable {
openBrowser();
final String [] items = getItems(count);

exercise(() -> {
list.removeAll();
startMeasuring();
for (String item : items) {
list.add(item);
}
processEvents();
stopMeasuring();
});

commitMeasurements();
assertPerformance();
Performance perf = Performance.getDefault();
String scenarioId = this.getClass().getName() + "." + testInfo.getDisplayName();
PerformanceMeter meter = perf.createPerformanceMeter(scenarioId);

try {
exercise(() -> {
list.removeAll();
meter.start();
for (String item : items) {
list.add(item);
}
processEvents();
meter.stop();
});

meter.commit();
perf.assertPerformance(meter);
} finally {
meter.dispose();
}
}

/**
* Test the time for adding elements using setItem.
*/
public void setItemsBench(int count) throws Throwable {
public void setItemsBench(int count, TestInfo testInfo) throws Throwable {
openBrowser();
final String [] items = getItems(count);
exercise(() -> {
list.removeAll();
startMeasuring();
list.setItems(items);
processEvents();
stopMeasuring();
});

commitMeasurements();
assertPerformance();

Performance perf = Performance.getDefault();
String scenarioId = this.getClass().getName() + "." + testInfo.getDisplayName();
PerformanceMeter meter = perf.createPerformanceMeter(scenarioId);

try {
exercise(() -> {
list.removeAll();
meter.start();
list.setItems(items);
processEvents();
meter.stop();
});

meter.commit();
perf.assertPerformance(meter);
} finally {
meter.dispose();
}
}

/**
Expand Down
Loading
Loading