コード例 #1
0
ファイル: MixedModeIRMethod.java プロジェクト: r6p/jruby
 public int getLine() {
   return method.getLineNumber();
 }
コード例 #2
0
ファイル: Interpreter.java プロジェクト: RB-DPR/RB-DPR
  private static void outputProfileStats() {
    ArrayList<IRScope> scopes = new ArrayList<IRScope>(scopeThreadPollCounts.keySet());
    Collections.sort(
        scopes,
        new java.util.Comparator<IRScope>() {
          @Override
          public int compare(IRScope a, IRScope b) {
            // In non-methods and non-closures, we may not have any thread poll instrs.
            int aden = a.getThreadPollInstrsCount();
            if (aden == 0) aden = 1;
            int bden = b.getThreadPollInstrsCount();
            if (bden == 0) bden = 1;

            // Use estimated instr count to order scopes -- rather than raw thread-poll count
            float aCount =
                scopeThreadPollCounts.get(a).count
                    * (1.0f * a.getInstrsForInterpretation().length / aden);
            float bCount =
                scopeThreadPollCounts.get(b).count
                    * (1.0f * b.getInstrsForInterpretation().length / bden);
            if (aCount == bCount) return 0;
            return (aCount < bCount) ? 1 : -1;
          }
        });

    /*
    LOG.info("------------------------");
    LOG.info("Stats after " + globalThreadPollCount + " thread polls:");
    LOG.info("------------------------");
    LOG.info("# instructions: " + interpInstrsCount);
    LOG.info("# code modifications in this period : " + codeModificationsCount);
    LOG.info("------------------------");
    */
    int i = 0;
    float f1 = 0.0f;
    for (IRScope s : scopes) {
      long n = scopeThreadPollCounts.get(s).count;
      float p1 = ((n * 1000) / globalThreadPollCount) / 10.0f;
      String msg =
          i
              + ". "
              + s
              + " [file:"
              + s.getFileName()
              + ":"
              + s.getLineNumber()
              + "] = "
              + n
              + "; ("
              + p1
              + "%)";
      if (s instanceof IRClosure) {
        IRMethod m = s.getNearestMethod();
        // if (m != null) LOG.info(msg + " -- nearest enclosing method: " + m);
        // else LOG.info(msg + " -- no enclosing method --");
      } else {
        // LOG.info(msg);
      }

      i++;
      f1 += p1;

      // Top 20 or those that account for 95% of thread poll events.
      if (i == 20 || f1 >= 95.0) break;
    }

    // reset code modification counter
    codeModificationsCount = 0;

    // Every 1M thread polls, discard stats by reallocating the thread-poll count map
    if (globalThreadPollCount % 1000000 == 0) {
      // System.out.println("---- resetting thread-poll counters ----");
      scopeThreadPollCounts = new HashMap<IRScope, Counter>();
      globalThreadPollCount = 0;
    }
  }