Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fcda75acc30b29ac3379af052d319fe010886d2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************************
 * Copyright (c) 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
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.p2.tests.perf;

import java.io.File;
import org.eclipse.core.tests.harness.PerformanceTestRunner;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;

/**
 * Performance tests for metadata repositories
 */
public class MetadataRepositoryPerformanceTest extends ProvisioningPerformanceTest {
	private static final int REPEATS = 5;
	protected File repoLocation;
	IMetadataRepository repository;

	protected void setUp() throws Exception {
		super.setUp();
		String tempDir = System.getProperty("java.io.tmpdir");
		repoLocation = new File(tempDir, "MetadataRepositoryPerformanceTest");
		delete(repoLocation);
		repoLocation.mkdir();
		IMetadataRepositoryManager manager = getMetadataRepositoryManager();
		repository = manager.createRepository(repoLocation.toURI(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null);
	}

	protected void tearDown() throws Exception {
		getMetadataRepositoryManager().removeRepository(repoLocation.toURI());
		delete(repoLocation);
		super.tearDown();
	}

	public void testQueryLocalRepository() {
		final int IU_COUNT = 3000;
		new PerformanceTestRunner() {
			IQuery[] queries = new IQuery[IU_COUNT];

			protected void setUp() {
				IInstallableUnit[] ius = new IInstallableUnit[IU_COUNT];
				for (int i = 0; i < ius.length; i++) {
					ius[i] = generateIU(i);
					queries[i] = new InstallableUnitQuery(ius[i].getId(), ius[i].getVersion());
				}
				repository.addInstallableUnits(ius);
			}

			protected void tearDown() {
			}

			protected void test() {
				for (int i = 0; i < queries.length; i++) {
					repository.query(queries[i], null);
				}
			}
		}.run(this, "Test query local metadata repo for " + IU_COUNT + " ius", REPEATS, 10);
	}
}

Back to the top