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
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-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;
public class SyncTests extends BenchmarkTest {
private static final int FILE_SIZE_MEAN = 16384;
private static final int FILE_SIZE_VARIANCE = 0;
private static final int PROB_BINARY = 0;
public SyncTests() {
super();
}
public SyncTests(String name) {
super(name);
}
public static Test suite() {
return suite(SyncTests.class);
}
public void testSync0() throws Exception {
// test sync on project with no changes
IProject project = setupOutProject();
startGroup("test sync with no changes");
syncCommitResources(new IResource[] { project }, "");
endGroup();
}
public void testSync1() throws Exception {
runTestSync(1);
}
public void testSync10() throws Exception {
runTestSync(10);
}
public void testSync100() throws Exception {
runTestSync(100);
}
protected IProject setupOutProject() throws Exception {
disableLog();
IProject project = createUniqueProject(BenchmarkTestSetup.SMALL_ZIP_FILE);
shareProject(project);
enableLog();
return project;
}
/**
* Runs a sequence of operations for the synchronizer tests.
* A parallel project is used to generate incoming changes.
*/
protected void runTestSync(int size) throws Exception {
final SequenceGenerator gen = new SequenceGenerator();
// setup out project then move it out of the way
IProject outProject = setupOutProject();
String moduleName = outProject.getName();
BenchmarkUtils.renameResource(outProject, moduleName + "out");
outProject = BenchmarkUtils.getProject(moduleName + "out");
// setup in project
IProject inProject = BenchmarkUtils.getProject(moduleName);
checkoutProject(inProject, moduleName, null);
/*** outgoing and incoming changes ***/
startGroup("synchronize " + size + " added file(s)");
BenchmarkUtils.createRandomDeepFiles(gen, outProject, size, FILE_SIZE_MEAN, FILE_SIZE_VARIANCE, PROB_BINARY);
startGroup("as outgoing changes");
syncCommitResources(new IResource[] { outProject }, "");
endGroup();
startGroup("as incoming changes");
syncUpdateResources(new IResource[] { inProject });
endGroup();
endGroup();
startGroup("synchronize " + size + " modified file(s)");
BenchmarkUtils.modifyRandomDeepFiles(gen, outProject, size);
startGroup("as outgoing changes");
syncCommitResources(new IResource[] { outProject }, "");
endGroup();
startGroup("as incoming changes");
syncUpdateResources(new IResource[] { inProject });
endGroup();
endGroup();
startGroup("synchronize " + size + " removed file(s)");
BenchmarkUtils.deleteRandomDeepFiles(gen, outProject, size);
startGroup("as outgoing changes");
syncCommitResources(new IResource[] { outProject }, "");
endGroup();
startGroup("as incoming changes");
syncUpdateResources(new IResource[] { inProject });
endGroup();
endGroup();
}
}
|