Questions tagged [getrusage]

getrusage() is a Unix function that measures resources used by the current process

47 questions
1
vote
1 answer

Should most of getrusage's fields be 0?

I've written two system calls in linux, and I measure both of their resource usages with getrusage within the system call. However, most of the results I get are 0, and I'm not sure if that makes sense. Here's the output: [ 4103.028728] DELTA…
Ramsey Alsheikh
  • 179
  • 1
  • 1
  • 7
1
vote
1 answer

Is getrusage not working for me? Why?

I'm trying to measure the maximum resident set size and I found that you can do so with getrusage: https://linux.die.net/man/2/getrusage http://pubs.opengroup.org/onlinepubs/009695399/functions/getrusage.html When I run this #include…
Sebastián
  • 11
  • 1
1
vote
1 answer

Why isn't the elapsed user time measured with getrusage() close to exactly consistent?

This C++ program gives variable results. Sometimes the variation is large. I call getrusage() once to get the start time. Then I call rand() 500000000 times in a loop. Then I call getrusage() again and output the elapsed user and system time…
WaltK
  • 724
  • 4
  • 13
1
vote
1 answer

How does getrusage() report time spent hibernating?

I am currently using getrusage to tell me how much time I spend in my application's event loop. I wonder how this will be affected by hibernating. Is hibernation time reported at all? Or perhaps as system time? Is this specified somewhere in Posix…
Yoric
  • 3,348
  • 3
  • 19
  • 26
1
vote
1 answer

How to find the idle time of a process

I have a process which in earlier release took some time. Now the same process in the current release is taking more time. But there are no changes in the code when compared to earlier. One observation I saw is there are some other processes on the…
user1939168
  • 547
  • 5
  • 20
1
vote
2 answers

How can I grap resident set size from Python on Solaris?

Calling resource.getrusage() from Python returns a 0 value for resident set size on Solaris and Linux systems. On Linux you can pull the RSS From /proc//status instead. Does anybody have a good way to pull RSS on Solaris, either similar or not to…
jasonjwwilliams
  • 2,541
  • 3
  • 19
  • 14
1
vote
1 answer

getrusage() get system time, user time. Unix programming help

I am writing a shell where I need to launch several child processes at once and record the system time and user time. So far I am able to do it. The only problem is that I am using wait4 to grab the system resources used by the child program and put…
user69514
  • 26,935
  • 59
  • 154
  • 188
0
votes
0 answers

getrusage for non-child process?

The man page for getrusage lists several modes: RUSAGE_SELF Return resource usage statistics for the calling process, which is the sum of resources used by all threads in the process. RUSAGE_CHILDREN Return…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
0
votes
1 answer

does cygwin support RUSAGE_THREAD in api int getrusage(int who, struct rusage *usage);?

we use api int getrusage(int who, struct rusage *usage); in Linux to calculate time in our code. We use constant RUSAGE_THREAD as argument in this api for the calling thread. As documented on the manual page RUSAGE_THREAD was introduced since Linux…
asad_nitp
  • 413
  • 1
  • 4
  • 8
0
votes
1 answer

What does this "alarm" error mean?

I am trying to get the memory consumed by an algorithm, so I have created a group of functions that would stop the execution in periods of 10 milliseconds to let me read the memory using the getrusage() function. The idea is to set a timer that will…
Jaime_mc2
  • 673
  • 5
  • 18
0
votes
1 answer

How does printf influence getrusage measure time in C

I probably missed some important point of getrusage() function. When I run the following code, I get: User time: 0.000000 s System time: 0.000000 s Total time: 0.000000 s void naiveSearch(unsigned char *text, unsigned int textLen,…
Preyt
  • 3
  • 2
0
votes
0 answers

Why tv_sec and tv_usec give unexpected result with getrusage()?

In this part of code, I am trying to use getrusage to measure time: getrusage(RUSAGE_SELF, &usage2); start2 = usage2.ru_stime; int counter; for (counter = 0; counter<10000; counter++) { int j; int found_elements =…
0
votes
2 answers

getrusage returning zeros in ru_utime.tv_usec and ru_utime.tv_sec

For the following code getrusage returning zeros in ru_utime.tv_usec and ru_utime.tv_sec. Code: #include "stdlib.h" #include "stdio.h" #include "sys/time.h" #include "sys/resource.h" int getr_return, who = RUSAGE_SELF; struct rusage…
user3370219
  • 1
  • 1
  • 2
0
votes
1 answer

How to use getrusage for reading page errors in C?

I'm trying to get the page faults when I run a program with two different parts. What I do is some operations using two matrix multiplication methods and try to figure out wich one causes more page faults. /Operations for method 1 getrusage…
Peter
  • 985
  • 3
  • 12
  • 14
0
votes
1 answer

rusage() measured in seconds or millseconds?

Hi I'm trying to get the system time and user time of applications being forked by a shell. I'm just not sure what kind of time I'm getting, seconds? milliseconds? Does anybody know? printf("System time: %ld.%06ld sec\n",usage.ru_stime.tv_sec,…
user69514
  • 26,935
  • 59
  • 154
  • 188