Esempio n. 1
0
  private StackFileInfo postSTackFile(
      StackFileInfo stackFileInfo, ParserConfig config, String filter, boolean isRecent) {
    if (stackFileInfo.getTotalWorkingCount() <= 0) {
      MessageBox messageBox =
          new MessageBox(
              m_parentComposite.getShell(), SWT.ICON_ERROR | SWT.YES | SWT.APPLICATION_MODAL);
      messageBox.setText("File open error");
      messageBox.setMessage(
          new StringBuilder(200)
              .append("A working thread is not exists in ")
              .append(stackFileInfo.getFilename())
              .append(". configure a ")
              .append(config.getConfigFilename())
              .append(". ")
              .toString());
      messageBox.open();
      return null;
    }

    if (!isRecent) {
      PreferenceManager prefManager = PreferenceManager.get();
      if (filter == null) {
        prefManager.addToStackFiles(stackFileInfo.getFilename());
      }
      prefManager.addToAnalyzedStackFiles(stackFileInfo.getFilename());
    }
    return stackFileInfo;
  }
Esempio n. 2
0
  public void analyzeFilterStack(String inputFilter, boolean isInclude) {
    String filter = null;
    if (inputFilter == null) {
      filter = getSelectedAnalyzedFunction();
    } else {
      filter = inputFilter;
    }

    if (filter == null) return;

    StackFileInfo stackFileInfo = getSelectedStackFileInfo();
    if (stackFileInfo == null) return;

    ParserConfigReader reader =
        new ParserConfigReader(stackFileInfo.getParserConfig().getConfigFilename());
    ParserConfig config = reader.read();

    StackFileInfo filteredStackFileInfo =
        processStackFile(
            StackParser.getWorkingThreadFilename(stackFileInfo.getFilename()),
            config,
            filter,
            false,
            isInclude);
    addProcessedStack(filteredStackFileInfo);
  }
Esempio n. 3
0
  public void viewServiceCall(String filter) {
    if (filter == null) return;

    StackFileInfo stackFileInfo = getSelectedStackFileInfo();
    if (stackFileInfo == null) return;

    String filename = StackParser.getWorkingThreadFilename(stackFileInfo.getFilename());
    int stackStartLine = stackFileInfo.getParserConfig().getStackStartLine();
    if (filename != null && filter != null) {
      getBrowser()
          .setText(
              HtmlUtils.filterServiceCall(
                  filename, filter, stackFileInfo.getParserConfig().getService(), stackStartLine));
    }
  }
Esempio n. 4
0
  public void viewThreadStack(String filter) {
    if (filter == null) return;

    StackFileInfo stackFileInfo = getSelectedStackFileInfo();
    if (stackFileInfo == null) return;

    String filename = StackParser.getWorkingThreadFilename(stackFileInfo.getFilename());
    int stackStartLine = stackFileInfo.getParserConfig().getStackStartLine();
    if (filename != null && filter != null) {
      Browser broswer = getBrowser();
      if (m_isExcludeStack)
        broswer.setText(
            HtmlUtils.filterThreadStack(
                filename,
                filter,
                stackFileInfo.getParserConfig().getExcludeStack(),
                stackStartLine));
      else broswer.setText(HtmlUtils.filterThreadStack(filename, filter, null, stackStartLine));
    }
  }
Esempio n. 5
0
  private void viewRawIndexFile() {
    Object object = getSelectedFromMainTree();
    if (object == null) {
      return;
    }
    if (!(object instanceof StackAnalyzedInfo)) {
      return;
    }
    StackAnalyzedInfo analyzedInfo = (StackAnalyzedInfo) object;
    if (analyzedInfo.getExtension().equals(StackParser.UNIQUE_EXT)) {
      return;
    }

    StackFileInfo stackFileInfo = analyzedInfo.getStackFileInfo();

    System.out.println("StackFile:" + stackFileInfo.toString());
    System.out.println("File:" + analyzedInfo.toString());

    String analyzedFilename =
        StackParser.getAnaylzedFilename(stackFileInfo.getFilename(), analyzedInfo.getExtension());
    File file = new File(analyzedFilename);
    if (!file.isFile()) return;

    BufferedReader reader = null;
    boolean isDetail = false;
    boolean isStart = false;
    try {
      reader = new BufferedReader(new FileReader(file));

      String line = null;
      int totalCount = 0;
      HashMap<String, Integer> map = new HashMap<String, Integer>();
      while ((line = reader.readLine()) != null) {
        line = line.trim();
        if (line.length() > 0) {
          isStart = true;
        }
        if (line.length() == 0) {
          if (isStart) {
            isDetail = true;
          }
          continue;
        }
        if (isDetail) {
          totalCount++;
          HtmlUtils.caculCounter(line, map);
        }
      }

      ArrayList<ValueObject> list = HtmlUtils.sortCounter(map);

      StringBuilder buffer = new StringBuilder(102400);
      buffer.append(HtmlUtils.getMainBodyStart());
      buffer.append(HtmlUtils.getCurrentConfigurationBody()).append("<br><br>");
      buffer.append("<b>[ ").append(stackFileInfo.getFilename()).append(" ]</b><BR>");
      buffer
          .append("<b>")
          .append(analyzedInfo.toString())
          .append(" - ")
          .append(analyzedFilename)
          .append("</b><br><br>");

      buffer.append(
          "<table border='1'><tr align='center'><th>Count</th><th>Percent</th><th>Class.method</th></tr>");
      int value;
      for (ValueObject valueObject : list) {
        value = valueObject.getValue();
        buffer
            .append("<tr><td align='right'>")
            .append(value)
            .append("</td><td align='right'>")
            .append((int) ((100 * value) / totalCount))
            .append('%')
            .append("</td>");
        buffer.append("<td align='left'>").append(valueObject.getKey()).append("</td></tr>");
      }
      buffer.append("</table>");
      buffer.append(HtmlUtils.getMainBodyEnd());

      displayContent(buffer.toString());
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    } finally {
      try {
        if (reader != null) reader.close();
      } catch (Exception ex) {
      }
    }
  }