### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.tests.rcp Index: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/performance/EmptyWorkbenchPerfTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.tests.rcp/Eclipse RCP Tests/org/eclipse/ui/tests/rcp/performance/EmptyWorkbenchPerfTest.java,v retrieving revision 1.5 diff -u -r1.5 EmptyWorkbenchPerfTest.java --- Eclipse RCP Tests/org/eclipse/ui/tests/rcp/performance/EmptyWorkbenchPerfTest.java 16 Mar 2007 17:59:53 -0000 1.5 +++ Eclipse RCP Tests/org/eclipse/ui/tests/rcp/performance/EmptyWorkbenchPerfTest.java 5 May 2009 15:45:41 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,81 +13,94 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.Performance; +import org.eclipse.test.performance.PerformanceMeter; import org.eclipse.test.performance.PerformanceTestCase; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.application.WorkbenchAdvisor; -import org.eclipse.ui.tests.rcp.util.IPerformanceMeterArray; -import org.eclipse.ui.tests.rcp.util.IntervalMeters; -import org.eclipse.ui.tests.rcp.util.RestoreWorkbenchIntervalMonitor; import org.eclipse.ui.tests.rcp.util.OpenWorkbenchIntervalMonitor; +import org.eclipse.ui.tests.rcp.util.RestoreWorkbenchIntervalMonitor; /** * @since 3.1 */ public class EmptyWorkbenchPerfTest extends PerformanceTestCase { - private static final int REPEAT_COUNT = 10; + private static final int REPEAT_COUNT = 25; public void testOpen() { Display display = PlatformUI.createDisplay(); - Performance perf = Performance.getDefault(); - String baseScenarioId = perf.getDefaultScenarioId(this); - IPerformanceMeterArray meters = new IntervalMeters(perf, baseScenarioId, OpenWorkbenchIntervalMonitor.intervalNames); + PerformanceMeter startupMeter = perf.createPerformanceMeter( baseScenarioId + " [open]"); + PerformanceMeter shutdownMeter = perf.createPerformanceMeter( baseScenarioId + " [close]"); + tagAsSummary("Open RCP App", Dimension.CPU_TIME); for (int i = 0; i < REPEAT_COUNT; ++i ) { - meters.start(OpenWorkbenchIntervalMonitor.firstInterval); + startupMeter.start(); int code = PlatformUI.createAndRunWorkbench(display, - new OpenWorkbenchIntervalMonitor(meters)); - meters.stop(OpenWorkbenchIntervalMonitor.finalInterval); - + new OpenWorkbenchIntervalMonitor(startupMeter, shutdownMeter)); + shutdownMeter.stop(); assertEquals(PlatformUI.RETURN_OK, code); } display.dispose(); assertTrue(display.isDisposed()); - - meters.commit(); - meters.assertPerformance(); - meters.dispose(); + startupMeter.commit(); + perf.assertPerformance(startupMeter); + + // The shutdown timer is currently < 50ms on all test machine. Due to the granularity of timers + // and inherent Java variability, values below 100ms usually can not be interpreted. + // Rather, check for the absolute value to be below threshold of 120ms. + // If the test goes above it, it probably needs to be investigated. + perf.assertPerformanceInAbsoluteBand(shutdownMeter, Dimension.CPU_TIME, 0, 120); + + startupMeter.dispose(); + shutdownMeter.dispose(); } public void testRestore() { Display display = PlatformUI.createDisplay(); - + Performance perf = Performance.getDefault(); + String baseScenarioId = perf.getDefaultScenarioId(this); + PerformanceMeter startupMeter = perf.createPerformanceMeter( baseScenarioId + " [open]"); + PerformanceMeter shutdownMeter = perf.createPerformanceMeter( baseScenarioId + " [close]"); + // create an advisor that will just start the workbench long enough to create // something to be restored later - WorkbenchAdvisor wa = new RestoreWorkbenchIntervalMonitor(); - + PerformanceMeter startupMeter0 = perf.createPerformanceMeter( baseScenarioId + " [0][open]"); + PerformanceMeter shutdownMeter0 = perf.createPerformanceMeter( baseScenarioId + " [0][close]"); + WorkbenchAdvisor wa = new RestoreWorkbenchIntervalMonitor(startupMeter0, shutdownMeter0, true); int code = PlatformUI.createAndRunWorkbench(display, wa); assertEquals(PlatformUI.RETURN_RESTART, code); assertFalse(display.isDisposed()); - - // the rest is a bunch of code to restore the workbench and monitor performance - // while doing so - - Performance perf = Performance.getDefault(); - - String baseScenarioId = perf.getDefaultScenarioId(this); - IPerformanceMeterArray meters = new IntervalMeters(perf, baseScenarioId, RestoreWorkbenchIntervalMonitor.intervalNames); - + startupMeter0.dispose(); + shutdownMeter0.dispose(); + tagAsSummary("Restore RCP App", Dimension.CPU_TIME); + // the rest is a bunch of code to restore the workbench and monitor performance + // while doing so for (int i = 0; i < REPEAT_COUNT; ++i ) { - meters.start(RestoreWorkbenchIntervalMonitor.firstInterval); + startupMeter.start(); code = PlatformUI.createAndRunWorkbench(display, - new RestoreWorkbenchIntervalMonitor(meters)); - meters.stop(RestoreWorkbenchIntervalMonitor.finalInterval); - + new RestoreWorkbenchIntervalMonitor(startupMeter, shutdownMeter, false)); + shutdownMeter.stop(); assertEquals(PlatformUI.RETURN_OK, code); } - - meters.commit(); - meters.assertPerformance(); - meters.dispose(); - + display.dispose(); assertTrue(display.isDisposed()); + + startupMeter.commit(); + perf.assertPerformance(startupMeter); + + // The shutdown timer is currently < 50ms on all test machine. Due to the granularity of timers + // and inherit Java variability, values below 100ms usually can not be interpreted. + // Rather, check for the absolute value to be below threshold of 120ms. + // If the test goes above it, it probably needs to be investigated. + perf.assertPerformanceInAbsoluteBand(shutdownMeter, Dimension.CPU_TIME, 0, 120); + + startupMeter.dispose(); + shutdownMeter.dispose(); } } Index: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/OpenWorkbenchIntervalMonitor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.tests.rcp/Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/OpenWorkbenchIntervalMonitor.java,v retrieving revision 1.5 diff -u -r1.5 OpenWorkbenchIntervalMonitor.java --- Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/OpenWorkbenchIntervalMonitor.java 23 Apr 2009 16:15:34 -0000 1.5 +++ Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/OpenWorkbenchIntervalMonitor.java 5 May 2009 15:45:41 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,10 +10,7 @@ *******************************************************************************/ package org.eclipse.ui.tests.rcp.util; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.application.IActionBarConfigurer; -import org.eclipse.ui.application.IWorkbenchConfigurer; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.test.performance.PerformanceMeter; import org.eclipse.ui.tests.harness.util.RCPTestWorkbenchAdvisor; @@ -25,97 +22,24 @@ */ public class OpenWorkbenchIntervalMonitor extends RCPTestWorkbenchAdvisor { - public static final String[] intervalNames = new String[] { - "open", //$NON-NLS-1$ - "close" //$NON-NLS-1$ - }; - - public static final int openInterval = 0; - public static final int closeInterval = 1; - - public static final int firstInterval = openInterval; - public static final int finalInterval = closeInterval; - -// public static final String[] intervalNames = new String[] { -// "to initialize", //$NON-NLS-1$ -// "initialize to preStartup", //$NON-NLS-1$ -// "preStartup to preWindowOpen", //$NON-NLS-1$ -// "preWindowOpen to fillActionBars", //$NON-NLS-1$ -// "fillActionBars to postWindowOpen", //$NON-NLS-1$ -// "postWindowOpen to postStartup", //$NON-NLS-1$ -// "preShutdown to postShutdown", //$NON-NLS-1$ -// "postShutdown to complete" //$NON-NLS-1$ -// }; -// -// public static final int initializeInterval = 0; -// public static final int preStartupInterval = 1; -// public static final int preWindowOpenInterval = 2; -// public static final int fillActionBarsInterval = 3; -// public static final int postWindowOpenInterval = 4; -// public static final int postStartupInterval = 5; -// public static final int shutdownInterval = 6; -// public static final int workbenchDestroyedInterval = 7; -// -// public static final int firstInterval = initializeInterval; -// public static final int finalInterval = workbenchDestroyedInterval; + private PerformanceMeter startupMeter; + private PerformanceMeter shutdownMeter; - private IPerformanceMeterArray meters; - - public OpenWorkbenchIntervalMonitor(IPerformanceMeterArray meters) { + public OpenWorkbenchIntervalMonitor(PerformanceMeter startupMeter, PerformanceMeter shutdownMeter) { super(2); - this.meters = meters; - } - - public void initialize(IWorkbenchConfigurer configurer) { -// meters.stop(initializeInterval); -// meters.start(preStartupInterval); - super.initialize(configurer); - } - - public void preStartup() { -// meters.stop(preStartupInterval); -// meters.start(preWindowOpenInterval); - super.preStartup(); - } - - public void preWindowOpen(IWorkbenchWindowConfigurer configurer) { -// meters.stop(preWindowOpenInterval); -// meters.start(fillActionBarsInterval); - super.preWindowOpen(configurer); - } - - public void fillActionBars(IWorkbenchWindow window, IActionBarConfigurer configurer, int flags) { -// meters.stop(fillActionBarsInterval); -// meters.start(postWindowOpenInterval); - super.fillActionBars(window, configurer, flags); - - } - - public void postWindowOpen(IWorkbenchWindowConfigurer configurer) { -// meters.stop(postWindowOpenInterval); -// meters.start(postStartupInterval); - super.postWindowOpen(configurer); + this.startupMeter = startupMeter; + this.shutdownMeter = shutdownMeter; } public void postStartup() { -// meters.stop(postStartupInterval); - meters.stop(openInterval); - - // no reason to track performace between when startup completes and shutdown starts + startupMeter.stop(); + // no reason to track performance between when startup completes and shutdown starts // since that is just testing overhead - super.postStartup(); } public boolean preShutdown() { -// meters.start(shutdownInterval); - meters.start(closeInterval); + shutdownMeter.start(); return super.preShutdown(); } - - public void postShutdown() { -// meters.stop(shutdownInterval); -// meters.start(workbenchDestroyedInterval); - super.postShutdown(); - } } Index: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/RestoreWorkbenchIntervalMonitor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.tests.rcp/Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/RestoreWorkbenchIntervalMonitor.java,v retrieving revision 1.5 diff -u -r1.5 RestoreWorkbenchIntervalMonitor.java --- Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/RestoreWorkbenchIntervalMonitor.java 23 Apr 2009 16:15:34 -0000 1.5 +++ Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/RestoreWorkbenchIntervalMonitor.java 5 May 2009 15:45:41 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,11 +11,8 @@ package org.eclipse.ui.tests.rcp.util; import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.WorkbenchException; -import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.test.performance.PerformanceMeter; import org.eclipse.ui.application.IWorkbenchConfigurer; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; import org.eclipse.ui.tests.harness.util.RCPTestWorkbenchAdvisor; @@ -27,128 +24,44 @@ */ public class RestoreWorkbenchIntervalMonitor extends RCPTestWorkbenchAdvisor { - public static final String[] intervalNames = new String[] { - "open", //$NON-NLS-1$ - "close" //$NON-NLS-1$ - }; - - public static final int openInterval = 0; - public static final int closeInterval = 1; - - public static final int firstInterval = openInterval; - public static final int finalInterval = closeInterval; + private PerformanceMeter startupMeter; + private PerformanceMeter shutdownMeter; private boolean createRestorableWorkbench = false; - private IPerformanceMeterArray meters = new NullMeters(); -// public static final String[] intervalNames = new String[] { -// "to initialize", //$NON-NLS-1$ -// "initialize to preStartup", //$NON-NLS-1$ -// "preStartup to preWindowOpen", //$NON-NLS-1$ -// "preWindowOpen to fillActionBars", //$NON-NLS-1$ -// "fillActionBars to postWindowRestore", //$NON-NLS-1$ -// "postWindowRestore to postWindowOpen", //$NON-NLS-1$ -// "postWindowOpen to postStartup", //$NON-NLS-1$ -// "preShutdown to postShutdown", //$NON-NLS-1$ -// "postShutdown to complete" //$NON-NLS-1$ -// }; -// -// public static final int initializeInterval = 0; -// public static final int preStartupInterval = 1; -// public static final int preWindowOpenInterval = 2; -// public static final int fillActionBarsInterval = 3; -// public static final int postWindowRestoreInterval = 4; -// public static final int postWindowOpenInterval = 5; -// public static final int postStartupInterval = 6; -// public static final int shutdownInterval = 7; -// public static final int workbenchDestroyedInterval = 8; -// -// public static final int firstInterval = initializeInterval; -// public static final int finalInterval = workbenchDestroyedInterval; -// -// private boolean createRestorableWorkbench = false; -// private IPerformanceMeterArray meters = new NullMeters(); - private IWorkbenchConfigurer workbenchConfigurer; /** - * The default behaviour is to create a workbench that can be restored later. This - * constructor starts that behaviour by setting a flag that will be checked in the + * The default behavior is to create a workbench that can be restored later. This + * constructor starts that behavior by setting a flag that will be checked in the * appropriate methods. */ - public RestoreWorkbenchIntervalMonitor() { - super(2); - createRestorableWorkbench = true; - } - - public RestoreWorkbenchIntervalMonitor(IPerformanceMeterArray meters) { + public RestoreWorkbenchIntervalMonitor(PerformanceMeter startupMeter, PerformanceMeter shutdownMeter, boolean createRestorableWorkbench) { super(2); - this.meters = meters; + this.startupMeter = startupMeter; + this.shutdownMeter = shutdownMeter; + this.createRestorableWorkbench = createRestorableWorkbench; } public void initialize(IWorkbenchConfigurer configurer) { -// meters.stop(initializeInterval); - super.initialize(configurer); workbenchConfigurer = configurer; workbenchConfigurer.setSaveAndRestore(true); - -// meters.start(preStartupInterval); - } - - public void preStartup() { -// meters.stop(preStartupInterval); - super.preStartup(); -// meters.start(preWindowOpenInterval); - } - - public void preWindowOpen(IWorkbenchWindowConfigurer configurer) { -// meters.stop(preWindowOpenInterval); - super.preWindowOpen(configurer); -// meters.start(fillActionBarsInterval); - } - - public void fillActionBars(IWorkbenchWindow window, IActionBarConfigurer configurer, int flags) { -// meters.stop(fillActionBarsInterval); - super.fillActionBars(window, configurer, flags); -// meters.start(postWindowRestoreInterval); - } - - public void postWindowRestore(IWorkbenchWindowConfigurer configurer) throws WorkbenchException { -// meters.stop(postWindowRestoreInterval); - super.postWindowRestore(configurer); -// meters.start(postWindowOpenInterval); - } - - public void postWindowOpen(IWorkbenchWindowConfigurer configurer) { -// meters.stop(postWindowOpenInterval); - super.postWindowOpen(configurer); -// meters.start(postStartupInterval); } public void postStartup() { -// meters.stop(postStartupInterval); - meters.stop(openInterval); - - // no reason to track performace between when startup completes and shutdown starts + startupMeter.stop(); + // no reason to track performance between when startup completes and shutdown starts // since that is just testing overhead - super.postStartup(); } public boolean preShutdown() { boolean ret = super.preShutdown(); -// meters.start(shutdownInterval); - meters.start(closeInterval); + shutdownMeter.start(); return ret; } - public void postShutdown() { -// meters.stop(shutdownInterval); - super.postShutdown(); -// meters.start(workbenchDestroyedInterval); - } - public void eventLoopIdle(Display d) { if (createRestorableWorkbench) workbenchConfigurer.getWorkbench().restart(); Index: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/NullMeters.java =================================================================== RCS file: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/NullMeters.java diff -N Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/NullMeters.java --- Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/NullMeters.java 16 Mar 2007 17:59:53 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.tests.rcp.util; - -/** - * An empty array of meters, all calls are ignored. - * - * @since 3.1 - */ -public class NullMeters implements IPerformanceMeterArray { - - public NullMeters() { - // do nothing - } - - public void start(int meterIndex) { - // do nothing - } - - public void stop(int meterIndex) { - // do nothing - } - - public void intervalBoundary(int completedIntervalIndex) { - // do nothing - } - - public void commit() { - // do nothing - } - - public void assertPerformance() { - // do nothing - } - - public void dispose() { - // do nothing - } -} Index: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IntervalMeters.java =================================================================== RCS file: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IntervalMeters.java diff -N Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IntervalMeters.java --- Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IntervalMeters.java 16 Mar 2007 17:59:53 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.tests.rcp.util; - -import org.eclipse.test.performance.Performance; -import org.eclipse.test.performance.PerformanceMeter; - -/** - * A set of meters that should be used to check performance of intervals. For example, this - * collection is used to check performance between all stages of the workbench life-cycle - * (the significant events are marked in the WorkbenchAdvisor callbacks). - * - * @since 3.1 - */ -public class IntervalMeters implements IPerformanceMeterArray { - - private Performance perf; - private String baseScenarioId; - - /** - * Clients instantiate the interval meter set as a specific size and are then responsible - * for controlling by index. - */ - private PerformanceMeter[] meters; - - /** - * Create an set of performance meters using the argument array of strings in the name - * for each one - * @param intervals - */ - public IntervalMeters(Performance perf, String baseScenarioId, String[] intervals) { - this.perf = perf; - this.baseScenarioId = baseScenarioId; - - meters = new PerformanceMeter[intervals.length]; - for (int i = 0; i < intervals.length; ++i) { - meters[i] = perf.createPerformanceMeter(getScenarioId(intervals[i])); - } - } - - private String getScenarioId(String intervalName) { - return baseScenarioId + " [" + intervalName + ']'; //$NON-NLS-1$ - } - - public void start(int meterIndex) { - meters[meterIndex].start(); - } - - public void stop(int meterIndex) { - meters[meterIndex].stop(); - } - - /** - * The interval at the argument has completed. Stop that meter and start the next. - * @param completedIntervalIndex - */ - public void intervalBoundary(int completedIntervalIndex) { - meters[completedIntervalIndex].stop(); - meters[completedIntervalIndex + 1].start(); - } - - public void commit() { - for (int i = 0; i < meters.length; ++i) - meters[i].commit(); - } - - public void assertPerformance() { - for (int i = 0; i < meters.length; ++i) - perf.assertPerformance(meters[i]); - } - - public void dispose() { - for (int i = 0; i < meters.length; ++i) - meters[i].dispose(); - } -} Index: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IPerformanceMeterArray.java =================================================================== RCS file: Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IPerformanceMeterArray.java diff -N Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IPerformanceMeterArray.java --- Eclipse RCP Tests/org/eclipse/ui/tests/rcp/util/IPerformanceMeterArray.java 16 Mar 2007 17:59:53 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.tests.rcp.util; - -/** - * An array of performance meters that can be used for things like interval timing. - * - * @since 3.1 - */ -public interface IPerformanceMeterArray { - - /** - * Start the meter at the argument index. - */ - public void start(int meterIndex); - - /** - * Stop the meter at the argument index. - */ - public void stop(int meterIndex); - - /** - * Commit all meters in this array. - */ - public void commit(); - - /** - * Assert the performance of all meters in this array. - */ - public void assertPerformance(); - - /** - * Dispose all meters in this array. - */ - public void dispose(); -}