title: How to get RAM and CPU time consumption ? Python App on Linux
body: <p>I'm trying to get the value of the CPU consumption and the RAM consumption of my Python App on a Linux embedded environnement using <code>Psutil</code> and <code>Memory_Profiler</code>. The thing is I can't get it done, or more accurately I think I don't understand exactly what I'm getting as a result. I find Psutil quite unclear about the values returned by the methods so I don't know exactly what I should use in my case.</p>
  <p>I've written this but I think this can't give me what I actually want:</p>
  <pre><code>f = open(&quot;mem_info.txt&quot;, &quot;w&quot;) 
  txt = &quot;Memory RAM : &quot; + str(process.memory_info().vms) + &quot; bytes&quot;
  txt3 = &quot;RAM details : &quot; + str(virtual_memory())
  txt2 = &quot;Memory Percent : &quot; + str(process.memory_percent(memtype=&quot;vms&quot;)) + &quot; %&quot;
  txt4 = &quot;CPU Time  : &quot; + str(process.cpu_times()) + &quot; s&quot;
  TXT = txt + &quot;\n&quot; + txt2 + &quot;\n\n&quot; + txt3 + &quot;\n\n&quot; + txt4 + &quot;\n&quot;
  f.write(TXT)
  f.close()
  </code></pre>
  <p>Output :</p>
  <pre><code>Memory RAM : 605085696 bytes
  Memory Percent : 19.297597042513864 %
  
  RAM details : svmem(total=3135549440, available=2531147776, percent=19.3, used=417918976, free=104349696, active=1263509504, inactive=1590898688, buffers=13201408, cached=2600079360, shared=17809408, slab=109674496)
  
  CPU Time  : pcputimes(user=0.54, system=0.07, children_user=6.99, children_system=0.34, iowait=0.61) s
  </code></pre>
  <p>Could someone tell me if I should use an other method ? Or If I used the right one, what result should I look at ? Should I like sum the different results printed in CPU Time ? But if I do so it's way to long for being the time of CPU used... PLease Help me ! :(</p>