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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*******************************************************************************
* Copyright (c) 2009, 2017 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 org.eclipse.core.tests.harness.PerformanceTestRunner;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.publisher.PublisherResult;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.QueryUtil;
/**
* Performance tests for the p2 publisher
*/
public class PublisherPerformanceTest extends ProvisioningPerformanceTest {
private static final int REPEATS = 5;
public void testQueryPublisherResult() {
final int IU_COUNT = 3000;
new PerformanceTestRunner() {
IQuery<IInstallableUnit>[] queries = new IQuery[IU_COUNT];
PublisherResult result;
@Override
protected void setUp() {
IInstallableUnit[] ius = new IInstallableUnit[IU_COUNT];
result = new PublisherResult();
for (int i = 0; i < ius.length; i++) {
ius[i] = generateIU(i);
result.addIU(ius[i], IPublisherResult.ROOT);
queries[i] = QueryUtil.createIUQuery(ius[i].getId(), ius[i].getVersion());
}
}
@Override
protected void tearDown() {
}
@Override
protected void test() {
for (int i = 0; i < queries.length; i++) {
result.query(queries[i], null);
}
}
}.run(this, "Test query PublisherResult for " + IU_COUNT + " ius", REPEATS, 10);
}
public void testLimitQueryPublisherResult() {
final int IU_COUNT = 3000;
new PerformanceTestRunner() {
IQuery<IInstallableUnit>[] queries = new IQuery[IU_COUNT];
PublisherResult result;
@Override
protected void setUp() {
IInstallableUnit[] ius = new IInstallableUnit[IU_COUNT];
result = new PublisherResult();
for (int i = 0; i < ius.length; i++) {
ius[i] = generateIU(i);
result.addIU(ius[i], IPublisherResult.ROOT);
queries[i] = QueryUtil.createLimitQuery(QueryUtil.createIUQuery(ius[i].getId(), ius[i].getVersion()), 1);
}
}
@Override
protected void tearDown() {
}
@Override
protected void test() {
for (int i = 0; i < queries.length; i++) {
result.query(queries[i], null);
}
}
}.run(this, "Test query PublisherResult for " + IU_COUNT + " ius", REPEATS, 10);
}
}
|