01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.tests.performance;
11:
12: import org.eclipse.ui.activities.IActivityManager;
13:
14: /**
15: * @since 3.1
16: *
17: */
18: public class GenerateIdentifiersTest extends BasicPerformanceTest {
19:
20: private int count;
21:
22: public GenerateIdentifiersTest(int numberOfIdentifiers) {
23: super ("Generate " + numberOfIdentifiers + " identifiers");
24: this .count = numberOfIdentifiers;
25: }
26:
27: protected void runTest() throws Throwable {
28: final IActivityManager activityManager = fWorkbench
29: .getActivitySupport().getActivityManager();
30:
31: exercise(new TestRunnable() {
32: public void run() throws Exception {
33: // construct the Identifiers to test
34: final String[] ids = new String[count];
35: for (int i = 0; i < ids.length; i++) {
36: long timestamp = System.currentTimeMillis();
37: ids[i] = "org.eclipse.jdt.ui/" + i + timestamp;
38: }
39:
40: startMeasuring();
41: for (int i = 0; i < ids.length; i++) {
42: activityManager.getIdentifier(ids[i]);
43: }
44: stopMeasuring();
45: }
46: });
47: commitMeasurements();
48: assertPerformance();
49: }
50: }
|