org.eclipse.xtext.util.StopWatch Java Examples

The following examples show how to use org.eclipse.xtext.util.StopWatch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testIncrementalBuildWithBigLibraryFile() throws Exception {
	IJavaProject project = workspace.createJavaProject("foo");
	workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	int NUM_OBJECTS = 40000;
	StopWatch timer = new StopWatch();
	IFile file = folder.getFile("Test_Library" + F_EXT);
	String contents = "namespace x { ";
	for (int i = 0; i < NUM_OBJECTS; i++) {
		contents += " object Foo" + i;
	}
	contents+="}";
	file.create(new StringInputStream(contents), true, workspace.monitor());
	logAndReset("Creating files", timer);
	workspace.build();
	for (int i =0;i<5;i++) {
		IFile f = folder.getFile("Referencing_"+i+F_EXT);
		logAndReset("Creating library file", timer);
		f.create(new StringInputStream("object Bar"+i+" references x.Foo1"), true, null);
		logAndReset("Auto build", timer);
		workspace.build();
	}
}
 
Example #2
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testFullBuildBigProject() throws Exception {
	IJavaProject project = workspace.createJavaProject("foo");
	workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	int NUM_FILES = 200;
	IFile[] files = new IFile[NUM_FILES];
	StopWatch timer = new StopWatch();
	for (int i = 0; i < NUM_FILES; i++) {
		IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
		files[i] = file;
		String contents = "object Foo" + i + " references Foo" + (i + 1);
		if (i == NUM_FILES)
			contents = "object Foo" + i;
		file.create(new StringInputStream(contents), true, workspace.monitor());
	}
	logAndReset("Creating files", timer);
	workspace.build();
	logAndReset("Auto build", timer);
}
 
Example #3
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testFullBuildBigProjectWithRefeernceToJar() throws Exception {
	IJavaProject project = workspace.createJavaProject("foo");
	workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	IFile jarFile = project.getProject().getFile("my.jar");
	jarFile.create(jarInputStream(new TextFile("my/element"+F_EXT,"object ReferenceMe")), true, workspace.monitor());
	workspace.addJarToClasspath(project, jarFile);
	
	int NUM_FILES = 2000;
	IFile[] files = new IFile[NUM_FILES];
	StopWatch timer = new StopWatch();
	for (int i = 0; i < NUM_FILES; i++) {
		IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
		files[i] = file;
		String contents = "object Foo" + i + " references ReferenceMe";
		file.create(new StringInputStream(contents), true, workspace.monitor());
	}
	logAndReset("Creating files", timer);
	workspace.build();
	logAndReset("Auto build", timer);
	IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
	for (IMarker iMarker : iMarkers) {
		System.out.println(iMarker.getAttribute(IMarker.MESSAGE));
	}
	assertEquals(0,iMarkers.length);
}
 
Example #4
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testFullBuildBigProjectWithLinkingErrors() throws Exception {
	IJavaProject project =  workspace.createJavaProject("foo");
	workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	int NUM_FILES = 200;
	IFile[] files = new IFile[NUM_FILES];
	StopWatch timer = new StopWatch();
	for (int i = 0; i < NUM_FILES; i++) {
		IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
		files[i] = file;
		String contents = "object Foo" + i + " references Foo" + (i * 1000);
		if (i == NUM_FILES)
			contents = "object Foo" + i;
		file.create(new StringInputStream(contents), true, workspace.monitor());
	}
	logAndReset("Creating files", timer);
	workspace.build();
	logAndReset("Auto build", timer);
	IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
	assertEquals(NUM_FILES-1,iMarkers.length);
}
 
Example #5
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testFullBuildBigProjectWithSyntaxErrors() throws Exception {
	IJavaProject project = workspace.createJavaProject("foo");
	workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	int NUM_FILES = 500;
	IFile[] files = new IFile[NUM_FILES];
	StopWatch timer = new StopWatch();
	for (int i = 0; i < NUM_FILES; i++) {
		IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
		files[i] = file;
		String contents = "object Foo" + i + " references Foo" + (i * 1000);
		if (i == NUM_FILES)
			contents = "object Foo" + i;
		file.create(new StringInputStream(contents), true, workspace.monitor());
	}
	logAndReset("Creating files", timer);
	workspace.build();
	logAndReset("Auto build", timer);
	IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
	assertEquals(NUM_FILES-1,iMarkers.length);
}
 
Example #6
Source File: DefaultQuickfixProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public List<IssueResolution> getResolutions(Issue issue) {
	StopWatch stopWatch = new StopWatch(logger);
	try {
		if (Diagnostic.LINKING_DIAGNOSTIC.equals(issue.getCode())) {
			List<IssueResolution> result = new ArrayList<IssueResolution>();
			result.addAll(getResolutionsForLinkingIssue(issue));
			result.addAll(super.getResolutions(issue));
			return result;
		} else
			return super.getResolutions(issue);
	} finally {
		stopWatch.resetAndLog("#getResolutions");			
	}
	
}
 
Example #7
Source File: XtendQuickfixProvider.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public List<IssueResolution> getResolutions(Issue issue) {
	StopWatch stopWatch = new StopWatch(logger);
	try {
		if(LINKING_ISSUE_CODES.contains(issue.getCode())){
			List<IssueResolution> result = new ArrayList<IssueResolution>();
			result.addAll(getResolutionsForLinkingIssue(issue));
			if(!result.isEmpty())
				return result;
		}
		
		return super.getResolutions(issue);
	} finally {
		stopWatch.resetAndLog("#getResolutions");
	}
}
 
Example #8
Source File: ProfilingTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testSimple() throws Exception {
		with(new IndexTestLanguageStandaloneSetup(){
			@Override
			public Injector createInjector() {
				return Guice.createInjector(new org.eclipse.xtext.index.IndexTestLanguageRuntimeModule(){
					@Override
					public java.lang.Class<? extends org.eclipse.xtext.scoping.IScopeProvider> bindIScopeProvider() {
						return OptimizedScopeProvider.class;
					}
				}
				);
			}
		});
		XtextResourceSet rs = get(XtextResourceSet.class);
		Resource outer = rs.createResource(URI.createURI("outer."+getCurrentFileExtension()));
		outer.load(new StringInputStream(outerFile(ELEMENTS)), null);
		Resource inner = rs.createResource(URI.createURI("inner."+getCurrentFileExtension()));
		StopWatch watch = new StopWatch();
		
		inner.load(new StringInputStream(generateFile(ELEMENTS)), null);
//		resource.load(new StringInputStream(generateFile(1000)), null);
		watch.resetAndLog("loading");
		EcoreUtil.resolveAll(inner);
		watch.resetAndLog("linking");
		
		assertTrue(inner.getErrors().size()+" errors ", inner.getErrors().isEmpty());
		Manager manager = get(IResourceDescription.Manager.class);
//		Yourkit.startTracing();
		IResourceDescription iResourceDescription = manager.getResourceDescription(inner);
		Sets.newHashSet(iResourceDescription.getReferenceDescriptions());
//		Yourkit.stopCpuProfiling();
		watch.resetAndLog("resourcedescriptions");
//		System.out.println(Sets.newHashSet(inner.getAllContents()).size());
	}
 
Example #9
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private void logAndReset(String string, StopWatch timer) {
	timer.resetAndLog(string);
}