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
3 changes: 3 additions & 0 deletions tests/org.eclipse.ui.tests.performance/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.208.0",
org.eclipse.ui.navigator.resources,
org.eclipse.ui.genericeditor
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
org.junit.jupiter.api.extension;version="[5.14.0,6.0.0)",
org.junit.jupiter.params;version="[5.14.0,6.0.0)",
org.junit.jupiter.params.provider;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,53 @@
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.eclipse.ui.tests.performance.UIPerformanceTestUtil.exercise;

import org.eclipse.test.performance.PerformanceTestCaseJunit4;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.eclipse.ui.activities.IActivityManager;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
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;

/**
* @since 3.1
*/
public class GenerateIdentifiersTest extends PerformanceTestCaseJunit4 {
public class GenerateIdentifiersTest {

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

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

private static final int count = 10000;

@Test
public void test() throws Throwable {
public void test(TestInfo testInfo) throws Throwable {
final IActivityManager activityManager = getWorkbench().getActivitySupport().getActivityManager();

exercise(() -> {
// construct the Identifiers to test
final String[] ids = new String[count];
for (int i = 0; i < ids.length; i++) {
long timestamp = System.currentTimeMillis();
ids[i] = "org.eclipse.jdt.ui/" + i + timestamp;
}

startMeasuring();
for (String id : ids) {
activityManager.getIdentifier(id);
}
stopMeasuring();
});
commitMeasurements();
assertPerformance();
Performance perf = Performance.getDefault();
String scenarioId = this.getClass().getName() + "." + testInfo.getDisplayName();
PerformanceMeter meter = perf.createPerformanceMeter(scenarioId);
try {
exercise(() -> {
// construct the Identifiers to test
final String[] ids = new String[count];
for (int i = 0; i < ids.length; i++) {
long timestamp = System.currentTimeMillis();
ids[i] = "org.eclipse.jdt.ui/" + i + timestamp;
}

meter.start();
for (String id : ids) {
activityManager.getIdentifier(id);
}
meter.stop();
});
meter.commit();
perf.assertPerformance(meter);
} finally {
meter.dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
import static org.eclipse.ui.tests.performance.UIPerformanceTestUtil.exercise;

import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Stream;

import org.eclipse.jface.tests.performance.JFacePerformanceSuite;
import org.eclipse.jface.viewers.CellLabelProvider;
Expand Down Expand Up @@ -47,30 +46,29 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.test.performance.PerformanceTestCaseJunit4;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
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.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

/**
* Test scrolling performance with various label styles
*
* @since 3.5
*/
@RunWith(Parameterized.class)
public class LabelProviderTest extends PerformanceTestCaseJunit4 {
public class LabelProviderTest {

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

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

private static class CountryEntry {
private final String name;
Expand Down Expand Up @@ -173,25 +171,14 @@ public Font getFont(Object element) {
private Shell fShell;
private StructuredViewer fViewer;

private final boolean styled;
private final boolean colors;

@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] { { true, true }, { true, false }, { false, true }, { false, false } });
}

/**
* @param styled <code>true</code> to use DecoratingStyledCellLabelProvider
* @param colors Run test with color on or off
*/
public LabelProviderTest(boolean styled, boolean colors) {
this.styled = styled;
this.colors = colors;
public static Stream<Arguments> data() {
return Stream.of(Arguments.of(true, true), Arguments.of(true, false), Arguments.of(false, true),
Arguments.of(false, false));
}

@Test
public void test() throws Throwable {
@ParameterizedTest
@MethodSource("data")
public void test(boolean styled, boolean colors, TestInfo testInfo) throws Throwable {
if (styled)
fViewer.setLabelProvider(getDecoratingStyledCellLabelProvider(colors));
else
Expand All @@ -200,17 +187,25 @@ public void test() throws Throwable {
final Tree tree = ((TreeViewer) fViewer).getTree();
fShell.setFocus();

exercise(() -> {
startMeasuring();
for (int i = 0; i < ITEM_COUNT / 5; i++) {
tree.setTopItem(tree.getItem(i * 5));
processEvents();
}
stopMeasuring();
}, MIN_ITERATIONS, ITERATIONS, JFacePerformanceSuite.MAX_TIME);

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

try {
exercise(() -> {
meter.start();
for (int i = 0; i < ITEM_COUNT / 5; i++) {
tree.setTopItem(tree.getItem(i * 5));
processEvents();
}
meter.stop();
}, MIN_ITERATIONS, ITERATIONS, JFacePerformanceSuite.MAX_TIME);

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

protected StructuredViewer createViewer(Shell parent) {
Expand Down Expand Up @@ -253,7 +248,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
return viewer;
}

@Before
@BeforeEach
public final void prepareShellUp() throws Exception {
Display display = Display.getCurrent();
if (display == null)
Expand All @@ -273,7 +268,7 @@ public final void prepareShellUp() throws Exception {
fShell.open();
}

@After
@AfterEach
public final void closeShell() throws Exception {
if (fShell != null) {
fShell.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.rules.ExternalResource;

public class UIPerformanceTestRule extends ExternalResource {
public class UIPerformanceTestRule extends ExternalResource implements BeforeAllCallback, AfterAllCallback {
public static final String PERSPECTIVE1 = "org.eclipse.ui.tests.performancePerspective1";
public static final String PERSPECTIVE2 = "org.eclipse.ui.tests.performancePerspective2";

Expand All @@ -34,6 +37,22 @@ public class UIPerformanceTestRule extends ExternalResource {
private static final String INTRO_VIEW = "org.eclipse.ui.internal.introview";
public static final String[] EDITOR_FILE_EXTENSIONS = { "perf_basic", "perf_outline", "perf_text" };

@Override
public void beforeAll(ExtensionContext context) throws Exception {
try {
before();
} catch (Exception e) {
throw e;
} catch (Throwable e) {
throw new RuntimeException(e);
}
}

@Override
public void afterAll(ExtensionContext context) throws Exception {
after();
}

@Override
protected void before() throws Throwable {
IWorkbench workbench = PlatformUI.getWorkbench();
Expand Down
Loading