getrusage() is a Unix function that measures resources used by the current process
Questions tagged [getrusage]
47 questions
2
votes
1 answer
What is the difference between these methods to obtain resource usage?
In Linux, we can use two ways to find out resources used like time, page faults, page swaps, context switching. One of the ways is using the getrusage() function, the other method is using the command /usr/bin/time -v [command to check usage]. What…

codeczar
- 273
- 1
- 8
- 22
2
votes
2 answers
Measure the maximum memory usage during a function call
I have a Linux/Mac C++ library that performs a series of steps, in the form of function calls. I would like to measure the maximum memory usage during each step.
I am not interested in ad-hoc solutions like starting another thread that polls memory…

Timmmm
- 88,195
- 71
- 364
- 509
2
votes
0 answers
C - using getrusage for children user and kernel time
I have this programming assignment in which I need to use the getrusage to find 'what the children is doing', as my professor said. I used the RUSAGE_CHILDREN mode of the getrusage function inside the 'default' section of the switch(fork()). I…

Andre Fox
- 61
- 8
2
votes
1 answer
getrusage on child process
I am working on a C program in which I have to fork() a process and use the getrusage() function for printing the user time and the kernel time of the child process.
This is my code:
#include
#include
#include…

Andre Fox
- 61
- 8
2
votes
0 answers
How to get CPU time used by a thread given its ID?
So I want to get the cpu time used by a thread given its ID. getrusage is not applicable here as getrusage(RUSAGE_THREAD, &r_usage); returns the resources used by the thread that calls it, here I want to get resources of a thread other than the one…

Dev2017
- 857
- 9
- 31
2
votes
2 answers
How to find total time used by the thread in C/C++?
I am trying to get the total time a particular thread spent so far programatically.
getrusage returns a thread's CPU time but I want the total time i.e. including the time spent by the thread being blocked for whatever reason.
Please note that I…

Dev2017
- 857
- 9
- 31
2
votes
2 answers
What do the user CPU time and system CPU time in getrusage(RUSAGE_THREAD, &r_usage) measure excactly?
So I am trying to know the time the current thread has been executing for so far. I am trying to use getrusage(RUSAGE_THREAD, &r_usage); for it. Here are my confusions:
1- Will the time returned by the this function include the time the threads…

Dev2017
- 857
- 9
- 31
2
votes
1 answer
Units of `ru_maxrss` on BSD?
getrusage returns a struct containing
long ru_maxrss; /* max resident set size */
What are the units of ru_maxrss, on BSD operating systems? Is this value in bytes, or in kilobytes? By "BSD", I mean FreeBSD, OpenBSD, but not Mac OS X /…

D.W.
- 3,382
- 7
- 44
- 110
2
votes
1 answer
/usr/bin/time file inputs / outputs
I'm struggling to find any detailed information about exactly what the various outputs of /usr/bin/time -v mean. Namely I'm confused about the meaning of file inputs / outputs.
If anyone has some experience with '/usr/bin/time' I'dd be grateful if…

osnoz
- 1,127
- 1
- 11
- 16
2
votes
2 answers
How can I get CPU usage of VM(KVM)
How can I get the cpu usage of vm in KVM like virt-manager?
virt-manager monitoring vm cpu usage
Libvirt didn't provide API.
Does anyone know how to get vm cpu usage from host?

dommgifer
- 71
- 1
- 1
- 7
2
votes
1 answer
using getrusage to get the time for parent and children
I am trying how to use getrusage function in c in linux environment and was wondering if I am on a right track.
I wrote a small program to make sure I understand how getrusage works before applying to my project. I want to get the user/kernel times…

Saik
- 993
- 1
- 16
- 40
2
votes
2 answers
Check Internet Usage using JAVA
How can I Check upload and download data capacities using Java Code?
(in internet or local area network)

vdeshan
- 153
- 1
- 13
1
vote
2 answers
How to programmatically get the CPU utilization by the parent thread and sibling threads, from a worker thread?
My multi-threaded application (c++) uses pthreads. The application automatically generates threads and re-uses them on-demand, and allows a thread to be cancelled when it's been idling for too long.
I have put in a "special thread" to capture…

mdk
- 6,225
- 1
- 25
- 30
1
vote
1 answer
What is the true getrusage resolution?
I'm trying to measure getrusage resolution via simple program:
#include
#include
#include
#include
int main(int argc, const char *argv[]) {
struct rusage u = {0};
…

Emanuele
- 1,408
- 1
- 15
- 39
1
vote
0 answers
What are the different values of rusage structure in getrusage() system call argument?
We use getrusage() system call to find different values of resources it takes two arguments in which the first argument is RUSAGE_SELF or RUSAGE_CHILDREN, the other argument is a structure named rusage. This structure has many elements which can be…

codeczar
- 273
- 1
- 8
- 22