001: /*******************************************************************************
002: * Copyright (c) 2004, 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.tests.rcp.util;
011:
012: import org.eclipse.ui.IWorkbenchWindow;
013: import org.eclipse.ui.application.IActionBarConfigurer;
014: import org.eclipse.ui.application.IWorkbenchConfigurer;
015: import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
016:
017: /**
018: * This implementation of the workbench advisor tracks performance for the intervals between
019: * lifecycle events.
020: *
021: * @since 3.1
022: */
023: public class OpenWorkbenchIntervalMonitor extends
024: RCPTestWorkbenchAdvisor {
025:
026: public static final String[] intervalNames = new String[] { "open", //$NON-NLS-1$
027: "close" //$NON-NLS-1$
028: };
029:
030: public static final int openInterval = 0;
031: public static final int closeInterval = 1;
032:
033: public static final int firstInterval = openInterval;
034: public static final int finalInterval = closeInterval;
035:
036: // public static final String[] intervalNames = new String[] {
037: // "to initialize", //$NON-NLS-1$
038: // "initialize to preStartup", //$NON-NLS-1$
039: // "preStartup to preWindowOpen", //$NON-NLS-1$
040: // "preWindowOpen to fillActionBars", //$NON-NLS-1$
041: // "fillActionBars to postWindowOpen", //$NON-NLS-1$
042: // "postWindowOpen to postStartup", //$NON-NLS-1$
043: // "preShutdown to postShutdown", //$NON-NLS-1$
044: // "postShutdown to complete" //$NON-NLS-1$
045: // };
046: //
047: // public static final int initializeInterval = 0;
048: // public static final int preStartupInterval = 1;
049: // public static final int preWindowOpenInterval = 2;
050: // public static final int fillActionBarsInterval = 3;
051: // public static final int postWindowOpenInterval = 4;
052: // public static final int postStartupInterval = 5;
053: // public static final int shutdownInterval = 6;
054: // public static final int workbenchDestroyedInterval = 7;
055: //
056: // public static final int firstInterval = initializeInterval;
057: // public static final int finalInterval = workbenchDestroyedInterval;
058:
059: private IPerformanceMeterArray meters;
060:
061: public OpenWorkbenchIntervalMonitor(IPerformanceMeterArray meters) {
062: super (2);
063: this .meters = meters;
064: }
065:
066: public void initialize(IWorkbenchConfigurer configurer) {
067: // meters.stop(initializeInterval);
068: // meters.start(preStartupInterval);
069: super .initialize(configurer);
070: }
071:
072: public void preStartup() {
073: // meters.stop(preStartupInterval);
074: // meters.start(preWindowOpenInterval);
075: super .preStartup();
076: }
077:
078: public void preWindowOpen(IWorkbenchWindowConfigurer configurer) {
079: // meters.stop(preWindowOpenInterval);
080: // meters.start(fillActionBarsInterval);
081: super .preWindowOpen(configurer);
082: }
083:
084: public void fillActionBars(IWorkbenchWindow window,
085: IActionBarConfigurer configurer, int flags) {
086: // meters.stop(fillActionBarsInterval);
087: // meters.start(postWindowOpenInterval);
088: super .fillActionBars(window, configurer, flags);
089:
090: }
091:
092: public void postWindowOpen(IWorkbenchWindowConfigurer configurer) {
093: // meters.stop(postWindowOpenInterval);
094: // meters.start(postStartupInterval);
095: super .postWindowOpen(configurer);
096: }
097:
098: public void postStartup() {
099: // meters.stop(postStartupInterval);
100: meters.stop(openInterval);
101:
102: // no reason to track performace between when startup completes and shutdown starts
103: // since that is just testing overhead
104:
105: super .postStartup();
106: }
107:
108: public boolean preShutdown() {
109: // meters.start(shutdownInterval);
110: meters.start(closeInterval);
111: return super .preShutdown();
112: }
113:
114: public void postShutdown() {
115: // meters.stop(shutdownInterval);
116: // meters.start(workbenchDestroyedInterval);
117: super.postShutdown();
118: }
119: }
|