Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2004, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2004, 2009 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 13-93
Link Here
|
13 |
import org.eclipse.swt.widgets.Display; |
13 |
import org.eclipse.swt.widgets.Display; |
14 |
import org.eclipse.test.performance.Dimension; |
14 |
import org.eclipse.test.performance.Dimension; |
15 |
import org.eclipse.test.performance.Performance; |
15 |
import org.eclipse.test.performance.Performance; |
|
|
16 |
import org.eclipse.test.performance.PerformanceMeter; |
16 |
import org.eclipse.test.performance.PerformanceTestCase; |
17 |
import org.eclipse.test.performance.PerformanceTestCase; |
17 |
import org.eclipse.ui.PlatformUI; |
18 |
import org.eclipse.ui.PlatformUI; |
18 |
import org.eclipse.ui.application.WorkbenchAdvisor; |
19 |
import org.eclipse.ui.application.WorkbenchAdvisor; |
19 |
import org.eclipse.ui.tests.rcp.util.IPerformanceMeterArray; |
|
|
20 |
import org.eclipse.ui.tests.rcp.util.IntervalMeters; |
21 |
import org.eclipse.ui.tests.rcp.util.RestoreWorkbenchIntervalMonitor; |
22 |
import org.eclipse.ui.tests.rcp.util.OpenWorkbenchIntervalMonitor; |
20 |
import org.eclipse.ui.tests.rcp.util.OpenWorkbenchIntervalMonitor; |
|
|
21 |
import org.eclipse.ui.tests.rcp.util.RestoreWorkbenchIntervalMonitor; |
23 |
|
22 |
|
24 |
/** |
23 |
/** |
25 |
* @since 3.1 |
24 |
* @since 3.1 |
26 |
*/ |
25 |
*/ |
27 |
public class EmptyWorkbenchPerfTest extends PerformanceTestCase { |
26 |
public class EmptyWorkbenchPerfTest extends PerformanceTestCase { |
28 |
|
27 |
|
29 |
private static final int REPEAT_COUNT = 10; |
28 |
private static final int REPEAT_COUNT = 25; |
30 |
|
29 |
|
31 |
public void testOpen() { |
30 |
public void testOpen() { |
32 |
Display display = PlatformUI.createDisplay(); |
31 |
Display display = PlatformUI.createDisplay(); |
33 |
|
|
|
34 |
Performance perf = Performance.getDefault(); |
32 |
Performance perf = Performance.getDefault(); |
35 |
|
|
|
36 |
String baseScenarioId = perf.getDefaultScenarioId(this); |
33 |
String baseScenarioId = perf.getDefaultScenarioId(this); |
37 |
IPerformanceMeterArray meters = new IntervalMeters(perf, baseScenarioId, OpenWorkbenchIntervalMonitor.intervalNames); |
34 |
PerformanceMeter startupMeter = perf.createPerformanceMeter( baseScenarioId + " [open]"); |
|
|
35 |
PerformanceMeter shutdownMeter = perf.createPerformanceMeter( baseScenarioId + " [close]"); |
36 |
|
38 |
tagAsSummary("Open RCP App", Dimension.CPU_TIME); |
37 |
tagAsSummary("Open RCP App", Dimension.CPU_TIME); |
39 |
for (int i = 0; i < REPEAT_COUNT; ++i ) { |
38 |
for (int i = 0; i < REPEAT_COUNT; ++i ) { |
40 |
meters.start(OpenWorkbenchIntervalMonitor.firstInterval); |
39 |
startupMeter.start(); |
41 |
int code = PlatformUI.createAndRunWorkbench(display, |
40 |
int code = PlatformUI.createAndRunWorkbench(display, |
42 |
new OpenWorkbenchIntervalMonitor(meters)); |
41 |
new OpenWorkbenchIntervalMonitor(startupMeter, shutdownMeter)); |
43 |
meters.stop(OpenWorkbenchIntervalMonitor.finalInterval); |
42 |
shutdownMeter.stop(); |
44 |
|
|
|
45 |
assertEquals(PlatformUI.RETURN_OK, code); |
43 |
assertEquals(PlatformUI.RETURN_OK, code); |
46 |
} |
44 |
} |
47 |
|
45 |
|
48 |
display.dispose(); |
46 |
display.dispose(); |
49 |
assertTrue(display.isDisposed()); |
47 |
assertTrue(display.isDisposed()); |
50 |
|
48 |
startupMeter.commit(); |
51 |
meters.commit(); |
49 |
perf.assertPerformance(startupMeter); |
52 |
meters.assertPerformance(); |
50 |
|
53 |
meters.dispose(); |
51 |
// The shutdown timer is currently < 50ms on all test machine. Due to the granularity of timers |
|
|
52 |
// and inherent Java variability, values below 100ms usually can not be interpreted. |
53 |
// Rather, check for the absolute value to be below threshold of 120ms. |
54 |
// If the test goes above it, it probably needs to be investigated. |
55 |
perf.assertPerformanceInAbsoluteBand(shutdownMeter, Dimension.CPU_TIME, 0, 120); |
56 |
|
57 |
startupMeter.dispose(); |
58 |
shutdownMeter.dispose(); |
54 |
} |
59 |
} |
55 |
|
60 |
|
56 |
public void testRestore() { |
61 |
public void testRestore() { |
57 |
Display display = PlatformUI.createDisplay(); |
62 |
Display display = PlatformUI.createDisplay(); |
58 |
|
63 |
Performance perf = Performance.getDefault(); |
|
|
64 |
String baseScenarioId = perf.getDefaultScenarioId(this); |
65 |
PerformanceMeter startupMeter = perf.createPerformanceMeter( baseScenarioId + " [open]"); |
66 |
PerformanceMeter shutdownMeter = perf.createPerformanceMeter( baseScenarioId + " [close]"); |
67 |
|
59 |
// create an advisor that will just start the workbench long enough to create |
68 |
// create an advisor that will just start the workbench long enough to create |
60 |
// something to be restored later |
69 |
// something to be restored later |
61 |
WorkbenchAdvisor wa = new RestoreWorkbenchIntervalMonitor(); |
70 |
PerformanceMeter startupMeter0 = perf.createPerformanceMeter( baseScenarioId + " [0][open]"); |
62 |
|
71 |
PerformanceMeter shutdownMeter0 = perf.createPerformanceMeter( baseScenarioId + " [0][close]"); |
|
|
72 |
WorkbenchAdvisor wa = new RestoreWorkbenchIntervalMonitor(startupMeter0, shutdownMeter0, true); |
63 |
int code = PlatformUI.createAndRunWorkbench(display, wa); |
73 |
int code = PlatformUI.createAndRunWorkbench(display, wa); |
64 |
assertEquals(PlatformUI.RETURN_RESTART, code); |
74 |
assertEquals(PlatformUI.RETURN_RESTART, code); |
65 |
assertFalse(display.isDisposed()); |
75 |
assertFalse(display.isDisposed()); |
66 |
|
76 |
startupMeter0.dispose(); |
67 |
// the rest is a bunch of code to restore the workbench and monitor performance |
77 |
shutdownMeter0.dispose(); |
68 |
// while doing so |
78 |
|
69 |
|
|
|
70 |
Performance perf = Performance.getDefault(); |
71 |
|
72 |
String baseScenarioId = perf.getDefaultScenarioId(this); |
73 |
IPerformanceMeterArray meters = new IntervalMeters(perf, baseScenarioId, RestoreWorkbenchIntervalMonitor.intervalNames); |
74 |
|
75 |
tagAsSummary("Restore RCP App", Dimension.CPU_TIME); |
79 |
tagAsSummary("Restore RCP App", Dimension.CPU_TIME); |
76 |
|
80 |
|
|
|
81 |
// the rest is a bunch of code to restore the workbench and monitor performance |
82 |
// while doing so |
77 |
for (int i = 0; i < REPEAT_COUNT; ++i ) { |
83 |
for (int i = 0; i < REPEAT_COUNT; ++i ) { |
78 |
meters.start(RestoreWorkbenchIntervalMonitor.firstInterval); |
84 |
startupMeter.start(); |
79 |
code = PlatformUI.createAndRunWorkbench(display, |
85 |
code = PlatformUI.createAndRunWorkbench(display, |
80 |
new RestoreWorkbenchIntervalMonitor(meters)); |
86 |
new RestoreWorkbenchIntervalMonitor(startupMeter, shutdownMeter, false)); |
81 |
meters.stop(RestoreWorkbenchIntervalMonitor.finalInterval); |
87 |
shutdownMeter.stop(); |
82 |
|
|
|
83 |
assertEquals(PlatformUI.RETURN_OK, code); |
88 |
assertEquals(PlatformUI.RETURN_OK, code); |
84 |
} |
89 |
} |
85 |
|
90 |
|
86 |
meters.commit(); |
|
|
87 |
meters.assertPerformance(); |
88 |
meters.dispose(); |
89 |
|
90 |
display.dispose(); |
91 |
display.dispose(); |
91 |
assertTrue(display.isDisposed()); |
92 |
assertTrue(display.isDisposed()); |
|
|
93 |
|
94 |
startupMeter.commit(); |
95 |
perf.assertPerformance(startupMeter); |
96 |
|
97 |
// The shutdown timer is currently < 50ms on all test machine. Due to the granularity of timers |
98 |
// and inherit Java variability, values below 100ms usually can not be interpreted. |
99 |
// Rather, check for the absolute value to be below threshold of 120ms. |
100 |
// If the test goes above it, it probably needs to be investigated. |
101 |
perf.assertPerformanceInAbsoluteBand(shutdownMeter, Dimension.CPU_TIME, 0, 120); |
102 |
|
103 |
startupMeter.dispose(); |
104 |
shutdownMeter.dispose(); |
92 |
} |
105 |
} |
93 |
} |
106 |
} |