Example #1
0
  /**
   * get current thread cpu usage data.
   *
   * @param pid process id
   * @param tid thread id
   * @return ThreadUsage
   */
  private ThreadUsage currentThreadUsage(final long pid, final long tid) {
    String file = getThreadStatFile(pid, tid);

    try {
      String cpuline = FileUtils.file2string(file);
      return new ThreadUsage(cpuline);
    } catch (IOException ioe) {
      System.err.println(String.format("cannot find stat of process: %d, thread: %d", pid, tid));
      System.exit(1);
      return null;
    }
  }
Example #2
0
  /**
   * get current process cpu usage data.
   *
   * @param pid process id
   * @return ProcessUsage
   */
  private ProcessUsage currentProcessUsage(final long pid) {
    String file = getProcessStatFile(pid);

    try {
      String cpuline = FileUtils.file2string(file);
      return new ProcessUsage(cpuline);
    } catch (IOException ioe) {
      System.err.println("cannot find stat of process: " + pid);
      System.exit(1);
      return null;
    }
  }