Package com.google.dart.engine.utilities.instrumentation

Examples of com.google.dart.engine.utilities.instrumentation.InstrumentationBuilder


    return basis.computeExportedLibraries(source);
  }

  @Override
  public HtmlElement computeHtmlElement(Source source) throws AnalysisException {
    InstrumentationBuilder instrumentation = Instrumentation.builder("Analysis-computeHtmlElement");
    checkThread(instrumentation);
    try {
      instrumentation.metric("contextId", contextId);
      return basis.computeHtmlElement(source);
    } catch (AnalysisException e) {
      recordAnalysisException(instrumentation, e);
      throw e;
    } finally {
      instrumentation.log();
    }

  }
View Full Code Here


    return basis.computeImportedLibraries(source);
  }

  @Override
  public SourceKind computeKindOf(Source source) {
    InstrumentationBuilder instrumentation = Instrumentation.builder("Analysis-computeKindOf");
    checkThread(instrumentation);
    try {
      instrumentation.metric("contextId", contextId);
      return basis.computeKindOf(source);
    } finally {
      instrumentation.log();
    }
  }
View Full Code Here

    }
  }

  @Override
  public LibraryElement computeLibraryElement(Source source) throws AnalysisException {
    InstrumentationBuilder instrumentation = Instrumentation.builder("Analysis-computeLibraryElement");
    checkThread(instrumentation);
    try {
      instrumentation.metric("contextId", contextId);
      return basis.computeLibraryElement(source);
    } catch (AnalysisException e) {
      recordAnalysisException(instrumentation, e);
      throw e;
    } finally {
      instrumentation.log();
    }
  }
View Full Code Here

   * @throws AnalysisException always
   */
  @DartBlockBody({"throw new AnalysisException(\"Could not resolve dart:core\");"})
  public static void missingCoreLibrary(AnalysisContext analysisContext, Source coreLibrarySource)
      throws AnalysisException {
    InstrumentationBuilder instrumentation = Instrumentation.builder("ErrorNoCoreLibrary");
    try {
      DartSdk sdk = analysisContext.getSourceFactory().getDartSdk();
      if (sdk == null) {
        instrumentation.data("sdkPath", "--null--");
      } else if (sdk instanceof DirectoryBasedDartSdk) {
        File directory = ((DirectoryBasedDartSdk) sdk).getDirectory();
        if (directory == null) {
          instrumentation.data("sdkDirectoryIsNull", true);
        } else {
          instrumentation.data("sdkDirectoryIsNull", false);
          instrumentation.data("sdkPath", directory.getAbsolutePath());
          instrumentation.data("sdkDirectoryExists", directory.exists());
        }
      } else {
        instrumentation.data("sdkPath", "--unknown--");
      }
      instrumentation.data("coreLibraryPath", coreLibrarySource.getFullName());
    } finally {
      instrumentation.log();
    }
    throw new AnalysisException("Could not resolve dart:core");
  }
View Full Code Here

   * @return the element representing the resolved library
   * @throws AnalysisException if the library could not be resolved for some reason
   */
  public LibraryElement resolveLibrary(Source librarySource,
      List<ResolvableLibrary> librariesInCycle) throws AnalysisException {
    InstrumentationBuilder instrumentation = Instrumentation.builder("dart.engine.LibraryResolver.resolveLibrary");
    try {
      instrumentation.data("fullName", librarySource.getFullName());
      //
      // Build the map of libraries that are known.
      //
      this.librariesInCycle = librariesInCycle;
      libraryMap = buildLibraryMap();
      ResolvableLibrary targetLibrary = libraryMap.get(librarySource);
      coreLibrary = libraryMap.get(coreLibrarySource);
      instrumentation.metric("buildLibraryMap", "complete");
      //
      // Build the element models representing the libraries being resolved. This is done in three
      // steps:
      //
      // 1. Build the basic element models without making any connections between elements other
      //    than the basic parent/child relationships. This includes building the elements
      //    representing the libraries, but excludes members defined in enums.
      // 2. Build the elements for the import and export directives. This requires that we have the
      //    elements built for the referenced libraries, but because of the possibility of circular
      //    references needs to happen after all of the library elements have been created.
      // 3. Build the members in enum declarations.
      // 4. Build the rest of the type model by connecting superclasses, mixins, and interfaces. This
      //    requires that we be able to compute the names visible in the libraries being resolved,
      //    which in turn requires that we have resolved the import directives.
      //
      buildElementModels();
      instrumentation.metric("buildElementModels", "complete");
      LibraryElement coreElement = coreLibrary.getLibraryElement();
      if (coreElement == null) {
        missingCoreLibrary(analysisContext, coreLibrarySource);
      }
      buildDirectiveModels();
      instrumentation.metric("buildDirectiveModels", "complete");
      typeProvider = new TypeProviderImpl(coreElement);
      buildEnumMembers();
      buildTypeHierarchies();
      instrumentation.metric("buildTypeHierarchies", "complete");
      //
      // Perform resolution and type analysis.
      //
      // TODO(brianwilkerson) Decide whether we want to resolve all of the libraries or whether we
      // want to only resolve the target library. The advantage to resolving everything is that we
      // have already done part of the work so we'll avoid duplicated effort. The disadvantage of
      // resolving everything is that we might do extra work that we don't really care about. Another
      // possibility is to add a parameter to this method and punt the decision to the clients.
      //
      //if (analyzeAll) {
      resolveReferencesAndTypes();
      instrumentation.metric("resolveReferencesAndTypes", "complete");
      //} else {
      //  resolveReferencesAndTypes(targetLibrary);
      //}
      performConstantEvaluation();
      instrumentation.metric("performConstantEvaluation", "complete");
      instrumentation.metric("librariesInCycles", librariesInCycle.size());
      for (ResolvableLibrary lib : librariesInCycle) {
        instrumentation.metric(
            "librariesInCycles-CompilationUnitSources-Size",
            lib.getCompilationUnitSources().length);
      }

      return targetLibrary.getLibraryElement();
    } finally {
      instrumentation.log();
    }
  }
View Full Code Here

   * @throws AnalysisException if the library could not be resolved for some reason
   */
  public LibraryElement resolveEmbeddedLibrary(Source librarySource, long modificationStamp,
      CompilationUnit unit, boolean fullAnalysis) throws AnalysisException {

    InstrumentationBuilder instrumentation = Instrumentation.builder("dart.engine.LibraryResolver.resolveEmbeddedLibrary");
    try {
      instrumentation.metric("fullAnalysis", fullAnalysis);
      instrumentation.data("fullName", librarySource.getFullName());
      //
      // Create the objects representing the library being resolved and the core library.
      //
      Library targetLibrary = createLibraryWithUnit(librarySource, modificationStamp, unit);
      coreLibrary = libraryMap.get(coreLibrarySource);
      if (coreLibrary == null) {
        // This will be true unless the library being analyzed is the core library.
        coreLibrary = createLibrary(coreLibrarySource);
        if (coreLibrary == null) {
          LibraryResolver2.missingCoreLibrary(analysisContext, coreLibrarySource);
        }
      }
      instrumentation.metric("createLibrary", "complete");
      //
      // Compute the set of libraries that need to be resolved together.
      //
      computeEmbeddedLibraryDependencies(targetLibrary, unit);
      librariesInCycles = computeLibrariesInCycles(targetLibrary);
      //
      // Build the element models representing the libraries being resolved. This is done in three
      // steps:
      //
      // 1. Build the basic element models without making any connections between elements other than
      //    the basic parent/child relationships. This includes building the elements representing the
      //    libraries.
      // 2. Build the elements for the import and export directives. This requires that we have the
      //    elements built for the referenced libraries, but because of the possibility of circular
      //    references needs to happen after all of the library elements have been created.
      // 3. Build the rest of the type model by connecting superclasses, mixins, and interfaces. This
      //    requires that we be able to compute the names visible in the libraries being resolved,
      //    which in turn requires that we have resolved the import directives.
      //
      buildElementModels();
      instrumentation.metric("buildElementModels", "complete");
      LibraryElement coreElement = coreLibrary.getLibraryElement();
      if (coreElement == null) {
        throw new AnalysisException("Could not resolve dart:core");
      }
      buildDirectiveModels();
      instrumentation.metric("buildDirectiveModels", "complete");
      typeProvider = new TypeProviderImpl(coreElement);
      buildTypeHierarchies();
      instrumentation.metric("buildTypeHierarchies", "complete");
      //
      // Perform resolution and type analysis.
      //
      // TODO(brianwilkerson) Decide whether we want to resolve all of the libraries or whether we
      // want to only resolve the target library. The advantage to resolving everything is that we
      // have already done part of the work so we'll avoid duplicated effort. The disadvantage of
      // resolving everything is that we might do extra work that we don't really care about. Another
      // possibility is to add a parameter to this method and punt the decision to the clients.
      //
      //if (analyzeAll) {
      resolveReferencesAndTypes();
      instrumentation.metric("resolveReferencesAndTypes", "complete");
      //} else {
      //  resolveReferencesAndTypes(targetLibrary);
      //}
      performConstantEvaluation();
      instrumentation.metric("performConstantEvaluation", "complete");
      return targetLibrary.getLibraryElement();
    } finally {
      instrumentation.log();
    }
  }
View Full Code Here

   * @return the element representing the resolved library
   * @throws AnalysisException if the library could not be resolved for some reason
   */
  public LibraryElement resolveLibrary(Source librarySource, boolean fullAnalysis)
      throws AnalysisException {
    InstrumentationBuilder instrumentation = Instrumentation.builder("dart.engine.LibraryResolver.resolveLibrary");
    try {
      instrumentation.metric("fullAnalysis", fullAnalysis);
      instrumentation.data("fullName", librarySource.getFullName());
      //
      // Create the objects representing the library being resolved and the core library.
      //
      Library targetLibrary = createLibrary(librarySource);
      coreLibrary = libraryMap.get(coreLibrarySource);
      if (coreLibrary == null) {
        // This will be true unless the library being analyzed is the core library.
        coreLibrary = createLibraryOrNull(coreLibrarySource);
        if (coreLibrary == null) {
          LibraryResolver2.missingCoreLibrary(analysisContext, coreLibrarySource);
        }
      }
      instrumentation.metric("createLibrary", "complete");
      //
      // Compute the set of libraries that need to be resolved together.
      //
      computeLibraryDependencies(targetLibrary);
      librariesInCycles = computeLibrariesInCycles(targetLibrary);
      //
      // Build the element models representing the libraries being resolved. This is done in three
      // steps:
      //
      // 1. Build the basic element models without making any connections between elements other
      //    than the basic parent/child relationships. This includes building the elements
      //    representing the libraries, but excludes members defined in enums.
      // 2. Build the elements for the import and export directives. This requires that we have the
      //    elements built for the referenced libraries, but because of the possibility of circular
      //    references needs to happen after all of the library elements have been created.
      // 3. Build the members in enum declarations.
      // 4. Build the rest of the type model by connecting superclasses, mixins, and interfaces. This
      //    requires that we be able to compute the names visible in the libraries being resolved,
      //    which in turn requires that we have resolved the import directives.
      //
      buildElementModels();
      instrumentation.metric("buildElementModels", "complete");
      LibraryElement coreElement = coreLibrary.getLibraryElement();
      if (coreElement == null) {
        throw new AnalysisException("Could not resolve dart:core");
      }
      buildDirectiveModels();
      instrumentation.metric("buildDirectiveModels", "complete");
      typeProvider = new TypeProviderImpl(coreElement);
      buildEnumMembers();
      buildTypeHierarchies();
      instrumentation.metric("buildTypeHierarchies", "complete");
      //
      // Perform resolution and type analysis.
      //
      // TODO(brianwilkerson) Decide whether we want to resolve all of the libraries or whether we
      // want to only resolve the target library. The advantage to resolving everything is that we
      // have already done part of the work so we'll avoid duplicated effort. The disadvantage of
      // resolving everything is that we might do extra work that we don't really care about. Another
      // possibility is to add a parameter to this method and punt the decision to the clients.
      //
      //if (analyzeAll) {
      resolveReferencesAndTypes();
      instrumentation.metric("resolveReferencesAndTypes", "complete");
      //} else {
      //  resolveReferencesAndTypes(targetLibrary);
      //}
      performConstantEvaluation();
      instrumentation.metric("performConstantEvaluation", "complete");
      instrumentation.metric("librariesInCycles", librariesInCycles.size());
      for (Library lib : librariesInCycles) {
        instrumentation.metric(
            "librariesInCycles-CompilationUnitSources-Size",
            lib.getCompilationUnitSources().size());
      }

      return targetLibrary.getLibraryElement();
    } finally {
      instrumentation.log(15); //Log if >= than 15ms
    }
  }
View Full Code Here

   * Scan the source code to produce a list of tokens representing the source.
   *
   * @return the first token in the list of tokens that were produced
   */
  public Token tokenize() {
    InstrumentationBuilder instrumentation = Instrumentation.builder("dart.engine.AbstractScanner.tokenize");
    int tokenCounter = 0;
    try {
      int next = reader.advance();
      while (next != -1) {
        tokenCounter++;
        next = bigSwitch(next);
      }
      appendEofToken();
      instrumentation.metric("tokensCount", tokenCounter);
      return getFirstToken();
    } finally {
      instrumentation.log(2); //Log if over 1ms
    }
  }
View Full Code Here

   *
   * @param token the first token of the compilation unit
   * @return the compilation unit that was parsed
   */
  public CompilationUnit parseCompilationUnit(Token token) {
    InstrumentationBuilder instrumentation = Instrumentation.builder("dart.engine.Parser.parseCompilationUnit");
    try {
      currentToken = token;
      return parseCompilationUnit();
    } finally {
      instrumentation.log(2); //Record if >= 2ms
    }
  }
View Full Code Here

   *
   * @param token the first token of the compilation unit
   * @return the compilation unit that was parsed
   */
  public CompilationUnit parseDirectives(Token token) {
    InstrumentationBuilder instrumentation = Instrumentation.builder("dart.engine.Parser.parseDirectives");
    try {
      currentToken = token;
      return parseDirectives();
    } finally {
      instrumentation.log(2); //Record if >= 2ms
    }
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.utilities.instrumentation.InstrumentationBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.