code: private double[] getSubProcessUsage(String pid,
                              Map<String, String[]> pidToContent,
                              Map<String, LinkedList<String>> pidToChildPid) {
      double cpuMemUsage[] = new double[2];
  
      Queue<String> pidQueue = new LinkedList<String>();
      pidQueue.add(pid);
      while (!pidQueue.isEmpty()) {
        pid = pidQueue.poll();
        for (String child : pidToChildPid.get(pid)) {
          pidQueue.add(child);
        }
        String[] psContent = pidToContent.get(pid);
        double cpuUsage = Double.parseDouble(psContent[PCPU]);
        cpuUsage = percentageToGHz(cpuUsage);
        double memUsage = Double.parseDouble(psContent[RSS]);
        // "ps -eo rss" gives memory in kB. We convert it in GB
        memUsage /= 1000000d;
        cpuMemUsage[0] += cpuUsage;
        cpuMemUsage[1] += memUsage;
      }
      return cpuMemUsage;
    }
docs: A function computes the Memory and CPU usage of all subprocess
  @param pid            PID of the process we are interested in
  @param pidToContent   Map between pid and the PS content
  @param pidToChildPid  Map between pid and pid of its child process
  @return A 2-element array which contants CPU and memory usage