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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*******************************************************************************
* Copyright (c) 2011 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.team.tests.ccvs.ui.benchmark;
import junit.framework.Test;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource;
import org.eclipse.team.tests.ccvs.ui.SubscriberParticipantSyncInfoSource;
/**
* The test performed by this class is used to compare the performance of the
* merge with and without the fix introduced in bug 315694.
* <p>
* When {@link CVSMergeSubscriber} is created with <code>isModelSync</code> flag
* set to <code>true</code>, which takes place when <code>MODEL_MERGE</code>
* group is started, the subscriber will *not* ignore outgoing changes during a
* merge. For more details see bug 315694.
*/
public class MergeTests extends BenchmarkTest {
private static final String NON_MODEL_MERGE = "NonModelMerge";
private static final String MODEL_MERGE = "ModelMerge";
private static final String[] PERFORMANCE_GROUPS = new String[] { NON_MODEL_MERGE, MODEL_MERGE };
private static final int FILE_SIZE_MEAN = 16384;
private static final int FILE_SIZE_VARIANCE = 0;
private static final int PROB_BINARY = 0;
public MergeTests() {
super();
}
public MergeTests(String name) {
super(name);
}
public static Test suite() {
return suite(MergeTests.class);
}
protected IProject setupProject() throws Exception {
IProject project = createUniqueProject(BenchmarkTestSetup.SMALL_ZIP_FILE);
shareProject(project);
return project;
}
public void testCompareMerges() throws Exception {
openEmptyPerspective();
setupGroups(PERFORMANCE_GROUPS, "Merge Tests", false);
System.out.println("Loop: " + BenchmarkTestSetup.LOOP_COUNT);
for (int i = 0; i < BenchmarkTestSetup.LOOP_COUNT; i++) {
final SequenceGenerator gen = new SequenceGenerator();
IProject headProject = setupProject();
CVSTag root = new CVSTag("Root_branch", CVSTag.BRANCH);
CVSTag branch = new CVSTag("branch", CVSTag.BRANCH);
makeBranch(new IResource[] {headProject}, root, branch, false);
IProject branchProject = checkoutCopy(headProject, branch);
SyncInfoSource source = new SubscriberParticipantSyncInfoSource();
int size = 50;
BenchmarkUtils.deleteRandomDeepFiles(gen, branchProject, size);
BenchmarkUtils.modifyRandomDeepFiles(gen, branchProject, size);
IResource[] newResources = BenchmarkUtils.createRandomDeepFiles(gen, branchProject, size, FILE_SIZE_MEAN, FILE_SIZE_VARIANCE, PROB_BINARY);
addResources(newResources);
syncCommitResources(source, new IResource[] { branchProject }, "");
BenchmarkUtils.deleteRandomDeepFiles(gen, headProject, size);
BenchmarkUtils.modifyRandomDeepFiles(gen, headProject, size);
BenchmarkUtils.createRandomDeepFiles(gen, headProject, size, FILE_SIZE_MEAN, FILE_SIZE_VARIANCE, PROB_BINARY);
startGroup(NON_MODEL_MERGE);
CVSMergeSubscriber subscriber = source.createMergeSubscriber(headProject, CVSTag.DEFAULT, branch, false);
source.refresh(subscriber, headProject);
endGroup();
startGroup(MODEL_MERGE);
subscriber = source.createMergeSubscriber(headProject, CVSTag.DEFAULT, branch, true);
source.refresh(subscriber, headProject);
endGroup();
System.out.println(i + 1);
}
commitGroups(false);
}
}
|