0

As mentioned in the title I am trying to find the different times listed below for my process:

Wall Time Spent Executing - The amount of time the process spent from start to finish. (i.e. the Real Time)

Total Time Spent on CPU - The amount of time the process spent executing instructions on the CPU plus the amount of time that the kernel was doing work on behalf of the process. (i.e. the Profile Time)

Time Spent in User Space - The amount of time the process spent executing instructions on the CPU. (i.e. the Virtual Time)

Time Spent in Kernel Space - The amount of time the kernel spent doing work on behalf of the process.

While searching I have found information on linux perf but I am unsure on how to use the package.

  • 3
    [time](https://linux.die.net/man/1/time). – kaylum Mar 12 '21 at 21:05
  • I'd just use the `time` command, like `time ./myprog`. – tadman Mar 12 '21 at 21:15
  • I am trying to determine the length of time for my fibonacci function to run. However this function can be ran for multiple different values and I would like to store the time it takes for each input. Would I be able to store each of the different times into a variable? @kaylum – Randell Persad Mar 12 '21 at 21:49
  • @tadman if you can answer the question also – Randell Persad Mar 12 '21 at 21:51
  • Then please update your question to clarify that you want function level times. That's not what it says at the moment. And no, `time` can't do that. Also, update your question to clearly state whether you want an external tool or whether adding code into your program is ok. – kaylum Mar 12 '21 at 21:51
  • If you're willing to instrument your code with special calls [what I'd do], you could have a look at `getitimer/setitimer` syscalls. But, most of the time spent will be in your user process, so, what I usually use is `clock_gettime(CLOCK_MONOTONIC,...)` – Craig Estey Mar 12 '21 at 23:15
  • But, what you may really want is the `times` syscall which gives system and user times for the process. – Craig Estey Mar 12 '21 at 23:29

0 Answers0