Exemplo n.º 1
0
  public void valueChanged(TreeSelectionEvent e) {
    TreeNode node = (TreeNode) e.getPath().getLastPathComponent();
    // System.out.println("valueChanged("+node+")");

    JipFrame frame = node.getFrameOrNull();
    JipMethod method = (frame == null) ? null : frame.getMethod();
    mMethodModel.setValue(method);
  }
Exemplo n.º 2
0
    public String toString() {
      if (mFrame == null) {
        return mLabel;
      }

      String label =
          ("("
              + toMsec(mFrame.getTotalTime())
              + " "
              + toMsec(mFrame.getNetTime())
              + " "
              + mFrame.getCount()
              + ") "
              + mFrame.getMethod().getMethodName());
      return label;
    }
Exemplo n.º 3
0
  private void buildFrameTree(TreeNode parent, JipFrame frame) {
    // compare for reverse total time.
    Comparator cmp =
        new Comparator<JipFrame>() {
          public int compare(JipFrame a, JipFrame b) {
            long timeA = a.getTotalTime();
            long timeB = b.getTotalTime();
            if (timeA > timeB) {
              return -1;
            } else if (timeA < timeB) {
              return 1;
            } else {
              String nameA = a.getMethod().getMethodName();
              String nameB = a.getMethod().getMethodName();
              return nameB.compareToIgnoreCase(nameA);
            }
          }
        };

    TreeNode frameNode = new TreeNode(frame);
    parent.add(frameNode);

    List<JipFrame> vKid = frame.getChildren();
    Collections.sort(vKid, cmp);
    for (JipFrame childFrame : vKid) {
      buildFrameTree(frameNode, childFrame);
    }
  }
Exemplo n.º 4
0
  private void buildTree(JipRun run, DefaultMutableTreeNode root) {
    for (Long threadId : run.threads()) {
      int i = 1;
      for (JipFrame f : run.interactions(threadId)) {
        String label =
            ("thread "
                + threadId
                + " interaction "
                + i
                + " ("
                + toMsec(f.getTotalTime())
                + " msec)");
        TreeNode interactionNode = new TreeNode(label);
        root.add(interactionNode);

        buildFrameTree(interactionNode, f);
        i++;
      }
    }
  }
Exemplo n.º 5
0
    public String toString() {
      if (mFrame == null) {
        return mLabel;
      }

      return String.format(
          "(%.1f  %.2f  %dx %.2fper) %s#%s",
          mFrame.getTotalTime() / NANOS_PER_MILLI,
          mFrame.getNetTime() / NANOS_PER_MILLI,
          mFrame.getCount(),
          mFrame.getNetTime() / NANOS_PER_MILLI / mFrame.getCount(),
          mFrame.getMethod().getClassName(),
          mFrame.getMethod().getMethodName());
    }
Exemplo n.º 6
0
 JipMethod getMethodOrNull() {
   return (mFrame == null) ? null : mFrame.getMethod();
 }
Exemplo n.º 7
0
  public JipViewer(String title, JipRun run) {
    super(title);

    addKeyListener(this);
    mMethodModel.addChangeListener(this);

    // build the call tree
    mCallTreeRoot = new TreeNode(title);
    buildTree(run, mCallTreeRoot);

    mCallTree = new JTree(mCallTreeRoot);
    mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    mCallTree.addTreeSelectionListener(this);
    mCallTree.addKeyListener(this);

    // build the allMethods table
    Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder();
    long totalTimeForAllThreads = run.getTotalTimeForAllThreads();
    for (JipRun.PerMethodInfo perMethod : perMethodInfos) {
      MethodRow row = new MethodRow(perMethod.getMethod());
      for (JipFrame frame : perMethod.allFrames()) {
        if (!frame.isReentrant()) {
          row.addFrame(frame);
        }
        row.setTimeDenominator(totalTimeForAllThreads);
      }
      mAllMethodsModel.add(row);
    }
    mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel);
    mMethods.getSelectionModel().addListSelectionListener(this);
    mMethods.addKeyListener(this);
    mAllMethodsSorterModel = (TableSorter) mMethods.getModel();

    // make the ByPackageViewer
    mPkgViewer = new ByPackageViewer(run);
    mPkgViewer.addKeyListener(this);

    // make the RemoteController
    mRemoteController = new RemoteController();
    mRemoteController.addKeyListener(this);

    // make the methodViewer
    MethodViewer methodViewer = new MethodViewer(run, mMethodModel);

    // combine all the views
    JTabbedPane tabPane = new JTabbedPane();
    tabPane.addTab("call tree", new JScrollPane(mCallTree));
    tabPane.addTab("methods", new JScrollPane(mMethods));
    tabPane.addTab("by package", new JScrollPane(mPkgViewer));
    tabPane.addTab("remote control", mRemoteController);
    tabPane.addTab("help", new HelpViewer());
    tabPane.addKeyListener(this);
    tabPane.setMinimumSize(new Dimension(100, 200));

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabPane, methodViewer);
    setContentPane(split);

    pack();
    setSize(new Dimension(1024, 768));
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Exemplo n.º 8
0
  public JipViewer(String title, JipRun run) {
    super(title);

    addKeyListener(this);
    mMethodModel.addChangeListener(this);

    // build the call tree
    mCallTreeRoot = new TreeNode(title);
    buildTree(run, mCallTreeRoot);

    mCallTree = new JTree(mCallTreeRoot);
    mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    mCallTree.addTreeSelectionListener(this);
    mCallTree.addKeyListener(this);

    // build the allMethods table
    Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder();
    long totalTimeForAllThreads = run.getTotalTimeForAllThreads();
    for (JipRun.PerMethodInfo perMethod : perMethodInfos) {
      MethodRow row = new MethodRow(perMethod.getMethod());
      for (JipFrame frame : perMethod.allFrames()) {
        if (!frame.isReentrant()) {
          row.addFrame(frame);
        }
        row.setTimeDenominator(totalTimeForAllThreads);
      }
      mAllMethodsModel.add(row);
    }
    mAllMethodsModel.sort();
    mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel);
    mMethods.getSelectionModel().addListSelectionListener(this);
    mMethods.addKeyListener(this);
    mAllMethodsSorterModel = (TableSorter) mMethods.getModel();

    // make the ByPackageViewer
    mPkgViewer = new ByPackageViewer(run);
    mPkgViewer.addKeyListener(this);

    // Make the classs count viewer

    mClassAllocationViewer = new ClassAllocationViewer(run);
    mClassAllocationViewer.addKeyListener(this);

    if (instanceNumero == 0) {
      // make the RemoteController only if root
      mRemoteController = new RemoteController();
      mRemoteController.addKeyListener(this);
    }

    // make the methodViewer
    MethodViewer methodViewerMethods = new MethodViewer(run, mMethodModel);
    MethodViewer methodViewerCallTree = new MethodViewer(run, mMethodModel);

    // combine all the views
    JTabbedPane tabPane = new JTabbedPane();
    if (instanceNumero != 0 || FIRST_HAS_DATA) {
      JSplitPane splitPane =
          new JSplitPane(
              JSplitPane.VERTICAL_SPLIT, new JScrollPane(mCallTree), methodViewerCallTree);
      splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS));
      tabPane.addTab("call tree", splitPane);
      splitPane =
          new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(mMethods), methodViewerMethods);
      splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS));
      tabPane.addTab("methods", splitPane);
      tabPane.addTab("by package", new JScrollPane(mPkgViewer));
      tabPane.addTab("class allocation", mClassAllocationViewer);
    }

    if (instanceNumero == 0) {
      tabPane.addTab("remote control", mRemoteController);
    }

    tabPane.addTab("help", new HelpViewer());
    tabPane.addKeyListener(this);
    setContentPane(tabPane);
    pack();
    setSize(new Dimension(1024, 768));
    setVisible(true);

    if (instanceNumero == 0) {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } else {
      setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    instanceNumero++;
  }