Java 类org.eclipse.xtext.util.StopWatch 实例源码

项目:bts    文件:DefaultQuickfixProvider.java   
@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");           
    }

}
项目:xtext-core    文件:ProfilingTest.java   
@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());
    }