Search in sources :

Example 1 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-eclipse by eclipse.

the class ProfilerAbstractBuilderTest method testLotsOfFiles.

@Test
public void testLotsOfFiles() throws Exception {
    IJavaProject project = workspace.createJavaProject("foo");
    workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
    IFolder folder = project.getProject().getFolder("src");
    int NUM_FILES = 10;
    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);
    for (int x = 0; x < 20; x++) {
        for (int i = 0; i < NUM_FILES; i++) {
            IFile file = files[i];
            String contents = "object Foo" + i + " references Foo" + (i + 1);
            if (i == NUM_FILES)
                contents = "object Foo" + i;
            file.setContents(new StringInputStream(contents), true, true, workspace.monitor());
            workspace.build();
        }
        logAndReset("updating all " + NUM_FILES + " files", timer);
    }
    assertEquals(NUM_FILES, countResourcesInIndex());
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IFolder(org.eclipse.core.resources.IFolder) StopWatch(org.eclipse.xtext.util.StopWatch) Test(org.junit.Test)

Example 2 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-eclipse by eclipse.

the class ProfilerAbstractBuilderTest method testFullBuildBigProject.

@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);
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IFolder(org.eclipse.core.resources.IFolder) StopWatch(org.eclipse.xtext.util.StopWatch) Test(org.junit.Test)

Example 3 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-eclipse by eclipse.

the class ProfilerAbstractBuilderTest method testIncrementalBuildWithBigLibraryFile.

@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();
    }
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IFolder(org.eclipse.core.resources.IFolder) StopWatch(org.eclipse.xtext.util.StopWatch) Test(org.junit.Test)

Example 4 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-eclipse by eclipse.

the class ProfilerAbstractBuilderTest method testFullBuildBigProjectWithSyntaxErrors.

@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);
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IMarker(org.eclipse.core.resources.IMarker) IFolder(org.eclipse.core.resources.IFolder) StopWatch(org.eclipse.xtext.util.StopWatch) Test(org.junit.Test)

Example 5 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-xtend by eclipse.

the class XtendQuickfixProvider method getResolutions.

@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");
    }
}
Also used : IssueResolution(org.eclipse.xtext.ui.editor.quickfix.IssueResolution) ArrayList(java.util.ArrayList) StopWatch(org.eclipse.xtext.util.StopWatch)

Aggregations

StopWatch (org.eclipse.xtext.util.StopWatch)9 StringInputStream (org.eclipse.xtext.util.StringInputStream)7 Test (org.junit.Test)7 IFile (org.eclipse.core.resources.IFile)6 IFolder (org.eclipse.core.resources.IFolder)6 IJavaProject (org.eclipse.jdt.core.IJavaProject)6 IMarker (org.eclipse.core.resources.IMarker)3 ArrayList (java.util.ArrayList)2 Injector (com.google.inject.Injector)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IndexTestLanguageStandaloneSetup (org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 Manager (org.eclipse.xtext.resource.IResourceDescription.Manager)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 IssueResolution (org.eclipse.xtext.ui.editor.quickfix.IssueResolution)1 TextFile (org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile)1