Package com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger

Examples of com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event


  private static final int MAX_EVENT_LOGS = 10000;

  public void testSpeedTracerLogger() throws IOException, JsonException {
    Writer writer = new StringWriter();
    SpeedTracerLogger logger = new SpeedTracerLogger(writer, Format.HTML);
    Event dummyOneEvent = logger.startImpl(null, dummyOne);
    Event dummyTwoEvent = logger.startImpl(null, dummyTwo);
    logger.endImpl(dummyTwoEvent);
    Event dummyThreeEvent = logger.startImpl(null, dummyThree);
    logger.endImpl(dummyThreeEvent);
    logger.endImpl(dummyOneEvent);
    logger.flush();

    Reader jsonReader = extractJsonFromWriter(writer);
View Full Code Here


  public void testSpeedTracerLoggerExtraData() throws IOException,
      JsonException {
    Writer writer = new StringWriter();
    SpeedTracerLogger logger = new SpeedTracerLogger(writer, Format.HTML);
    Event dummyOneEvent = logger.startImpl(null, dummyOne, "extraStart", "valueStart");
    logger.addDataImpl("extraMiddle", "valueMiddle");
    logger.endImpl(dummyOneEvent, "extraEnd", "valueEnd");
    logger.flush();

    Reader jsonReader = extractJsonFromWriter(writer);
View Full Code Here

  }

  public void testSpeedTracerLoggerMultiple() throws IOException, JsonException {
    Writer writer = new StringWriter();
    SpeedTracerLogger logger = new SpeedTracerLogger(writer, Format.HTML);
    Event dummyOneEvent = logger.startImpl(null, dummyOne);
    logger.endImpl(dummyOneEvent);
    Event dummyTwoEvent = logger.startImpl(null, dummyTwo);
    logger.endImpl(dummyTwoEvent);
    Event dummyThreeEvent = logger.startImpl(null, dummyThree);
    logger.endImpl(dummyThreeEvent);
    logger.flush();

    Reader jsonReader = extractJsonFromWriter(writer);
    JsonObject dummyOneObject = JsonObject.parse(jsonReader).asObject();
View Full Code Here

  }

  public void testSpeedTracerLoggerMarkTimeline() throws IOException, JsonException {
   Writer writer = new StringWriter();
    SpeedTracerLogger logger = new SpeedTracerLogger(writer, Format.RAW);
    Event dummyOneEvent = logger.startImpl(null, dummyOne);
    logger.markTimelineImpl("Test Message");
    dummyOneEvent.end();
    logger.flush();

    // There should be no HTML in here
    String logString = writer.toString();
    BufferedReader jsonReader = new BufferedReader(new StringReader(logString));
View Full Code Here


  public void testSpeedTracerLoggerRaw() throws IOException, JsonException {
   Writer writer = new StringWriter();
    SpeedTracerLogger logger = new SpeedTracerLogger(writer, Format.RAW);
    Event dummyOneEvent = logger.startImpl(null, dummyOne);
    dummyOneEvent.end();
    logger.flush();

    // There should be no HTML in here
    String logString = writer.toString();
    assertTrue(logString.trim().startsWith("{"));
View Full Code Here

    }

    @Override
    public void run() {
      for (int i = 0; i < MAX_EVENT_LOGS; i++) {
        Event e = logger.startImpl(null, event);
        logger.endImpl(e);
      }
    }
View Full Code Here

      // expected values (used in final assertions below)
      LinkedList<DevModeEvent> expectedEvents = new LinkedList<DevModeEvent>();
      LinkedList<DevModeSession> expectedSessions = new LinkedList<DevModeSession>();

      Event evt1, evt2;

      // test events with no session specified
      evt1 = SpeedTracerLogger.start(DevModeEventType.MODULE_INIT, "k1", "v1", "k2", "v2");
      // also test that child events aren't posted (only top-level events)
      evt2 = SpeedTracerLogger.start(DevModeEventType.CLASS_BYTES_REWRITE);
      evt2.end();
      evt1.end();
      // expect only first event
      expectedEvents.add(new DevModeEvent(evt1));
      expectedSessions.add(session1); // event should get "default" session

      // now with session specified
      evt1 = SpeedTracerLogger.start(session2, DevModeEventType.JAVA_TO_JS_CALL, "k1", "v1");
      // also test that child events aren't posted (only top-level events)
      evt2 = SpeedTracerLogger.start(DevModeEventType.CREATE_UI);
      evt2.end();
      evt1.end();
      // expect only first event
      expectedEvents.add(new DevModeEvent(evt1));
      expectedSessions.add(session2);

      evt1 = SpeedTracerLogger.start(session1, DevModeEventType.JS_TO_JAVA_CALL, "k1", "v1");
      evt1.end();
      expectedEvents.add(new DevModeEvent(evt1));
      expectedSessions.add(session1);

      // Finally, assert that the events and corresponding sessions sent to the
      // notifier are exactly as expected
View Full Code Here

  /**
   * Serializes an object and writes it to a file.
   */
  public static void writeObjectAsFile(TreeLogger logger, File file,
      Object... objects) throws UnableToCompleteException {
    Event writeObjectAsFileEvent = SpeedTracerLogger.start(CompilerEventType.WRITE_OBJECT_AS_FILE);
    FileOutputStream stream = null;
    try {
      // No need to check mkdirs result because an IOException will occur anyway
      file.getParentFile().mkdirs();
      stream = new FileOutputStream(file);
      writeObjectToStream(stream, objects);
    } catch (IOException e) {
      logger.log(TreeLogger.ERROR, "Unable to write file: "
          + file.getAbsolutePath(), e);
      throw new UnableToCompleteException();
    } finally {
      Utility.close(stream);
      writeObjectAsFileEvent.end();
    }
  }
View Full Code Here

  /**
   * Preinitializes the classpath for a given {@link ResourceLoader}.
   */
  public static void preload(TreeLogger logger, ResourceLoader resources) {
    Event resourceOracle =
        SpeedTracerLogger.start(CompilerEventType.RESOURCE_ORACLE, "phase", "preload");
    List<ClassPathEntry> entries = getAllClassPathEntries(logger, resources);
    for (ClassPathEntry entry : entries) {
      // We only handle pre-indexing jars, the file system could change.
      if (entry instanceof ZipFileClassPathEntry) {
        ZipFileClassPathEntry zpe = (ZipFileClassPathEntry) entry;
        zpe.index(logger);
      }
    }
    resourceOracle.end();
  }
View Full Code Here

   * Scans the associated paths to recompute the available resources.
   *
   * @param logger status and error details are written here
   */
  public synchronized void scanResources(TreeLogger logger) {
    Event resourceOracle =
        SpeedTracerLogger.start(CompilerEventType.RESOURCE_ORACLE, "phase", "refresh");
    TreeLogger refreshBranch = Messages.REFRESHING_RESOURCES.branch(logger, null);

    Map<String, ResourceDescription> resourceDescriptionsByPath =
        new LinkedHashMap<String, ResourceDescription>();

    for (ClassPathEntry classPathEntry : classPathEntries) {
      TreeLogger branchForClassPathEntry =
          Messages.EXAMINING_PATH_ROOT.branch(refreshBranch, classPathEntry.getLocation(), null);

      Map<AbstractResource, ResourceResolution> prefixesByResource =
          classPathEntry.findApplicableResources(branchForClassPathEntry, pathPrefixSet);
      for (Entry<AbstractResource, ResourceResolution> entry : prefixesByResource.entrySet()) {
        AbstractResource resource = entry.getKey();
        ResourceResolution resourceResolution = entry.getValue();
        ResourceDescription resourceDescription =
            new ResourceDescription(resource, resourceResolution.getPathPrefix());
        String resourcePath = resourceDescription.resource.getPath();
        maybeRecordTypeForModule(resourceResolution, resourcePath);
        maybeRecordOverlapWarning(resourceResolution, resourcePath);

        // In case of collision.
        if (resourceDescriptionsByPath.containsKey(resourcePath)) {
          ResourceDescription oldResourceDescription = resourceDescriptionsByPath.get(resourcePath);
          if (resourceDescription.isPreferredOver(oldResourceDescription)) {
            resourceDescriptionsByPath.put(resourcePath, resourceDescription);
          } else {
            Messages.IGNORING_SHADOWED_RESOURCE.log(branchForClassPathEntry, resourcePath, null);
          }
        } else {
          resourceDescriptionsByPath.put(resourcePath, resourceDescription);
        }
      }
    }

    Map<String, Resource> resourcesByPath = new HashMap<String, Resource>();
    for (Entry<String, ResourceDescription> entry : resourceDescriptionsByPath.entrySet()) {
      resourcesByPath.put(entry.getKey(), entry.getValue().resource);
    }

    // Update exposed collections with new (unmodifiable) data structures.
    exposedResources = Collections.unmodifiableSet(Sets.newHashSet(resourcesByPath.values()));
    exposedResourceMap = Collections.unmodifiableMap(resourcesByPath);
    exposedPathNames = Collections.unmodifiableSet(resourcesByPath.keySet());

    resourceOracle.end();
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event

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.