Skip to main content
summaryrefslogtreecommitdiffstats
blob: c6eea28993fd70079110247a05a79d8770c5366f (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
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
/*******************************************************************************
 * 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;
	
	private static final String ADDED_GROUP_SUFFIX = "AddedFiles";
	private static final String REMOVED_GROUP_SUFFIX = "RemovedFiles";
	private static final String MODIFIED_GROUP_SUFFIX = "ModifiedFiles";
    private static final String[] PERFORMANCE_GROUPS = new String[] {ADDED_GROUP_SUFFIX, MODIFIED_GROUP_SUFFIX, REMOVED_GROUP_SUFFIX};
	
	public SyncTests() {
		super();
	}

	public SyncTests(String name) {
		super(name);
	}

	public static Test suite() {
		return suite(SyncTests.class);
	}
    
	public void testSync10() throws Exception {
		runTestSync(10, "CVS Synchronize 10", false);
	}

	public void testSync100() throws Exception {
		runTestSync(100, "CVS Synchronize 100", false);
	}
	
	public void testSync100Global() throws Exception {
		runTestSync(100, "CVS Synchronize", true);
	}

	protected IProject setupOutProject() throws Exception {
		IProject project = createUniqueProject(BenchmarkTestSetup.SMALL_ZIP_FILE);
		shareProject(project);
		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, String globalName, boolean global) throws Exception {
	    setupGroups(PERFORMANCE_GROUPS, globalName, global);
	    for (int i = 0; i < BenchmarkTestSetup.LOOP_COUNT; i++) {
			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(ADDED_GROUP_SUFFIX);
			BenchmarkUtils.createRandomDeepFiles(gen, outProject, size, FILE_SIZE_MEAN, FILE_SIZE_VARIANCE, PROB_BINARY);
			syncCommitResources(new IResource[] { outProject }, "");
			syncUpdateResources(new IResource[] { inProject });
			endGroup();
			
			startGroup(MODIFIED_GROUP_SUFFIX);
			BenchmarkUtils.modifyRandomDeepFiles(gen, outProject, size);
			syncCommitResources(new IResource[] { outProject }, "");
			syncUpdateResources(new IResource[] { inProject });
			endGroup();
	
			startGroup(REMOVED_GROUP_SUFFIX);
			BenchmarkUtils.deleteRandomDeepFiles(gen, outProject, size);
			syncCommitResources(new IResource[] { outProject }, "");
			syncUpdateResources(new IResource[] { inProject });
			endGroup();
        }
	    commitGroups(global);
	}
}

Back to the top