49
questions
0
votes
0
answers
12
views
How I know the usage cost for each API key in Deepgram
I have the problem with api key usage for Deepgram service.
We support the speech to text service to customer companies with different API keys in Deepgram.
I can see and check log of usage. But I ...
0
votes
0
answers
105
views
getrusage() not giving the correct rss value for the Child process
I have written the following code in C++ to run a C++ code in a sandboxed env and then getting its memory usage
int main() {
int pid = fork();
if(pid == -1){
perror("fork");
...
1
vote
0
answers
138
views
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 ...
1
vote
1
answer
338
views
What is the true getrusage resolution?
I'm trying to measure getrusage resolution via simple program:
#include <cstdio>
#include <sys/time.h>
#include <sys/resource.h>
#include <cassert>
int main(int argc, const ...
0
votes
1
answer
88
views
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 ...
3
votes
1
answer
94
views
Resource Allocation of a C executable on two different Linux Computers
I am compiling and running the following c file on two different linux computers (Arch on Huawei Laptop 8GB RAM, Ubuntu on iMac 2017 32GB RAM).
#include <stdio.h>
#include <sys/resource.h>...
2
votes
1
answer
490
views
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 ...
1
vote
0
answers
666
views
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 ...
1
vote
1
answer
133
views
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 ...
1
vote
1
answer
760
views
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/...
2
votes
2
answers
1k
views
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 ...
4
votes
0
answers
380
views
Portable equivalent to getrusage() in C++?
We're using getrusage() when compiling on Linux to gain some insights into how much CPU-time some operations take in each thread:
getrusage(RUSAGE_THREAD, &before);
.... do work ....
getrusage(...
4
votes
2
answers
2k
views
Linux getrusage() maxrss maximum resident set size not increasing with allocation (C++)
I am trying to use getrusage(.) and maximum resident set size (maxrss) to check for memory leaks. However, when i purposely try to create a leak, maxrss does not change. Maybe i am not understanding ...
3
votes
1
answer
101
views
Does compilation of a program store some data in cache before execution?? (C, Linux)
Does compilation of a program store some data in cache before execution?
I wrote a C program in Linux that starts Sublime Text in one thread and makes manual system calls in another thread. (I'll ...
2
votes
0
answers
355
views
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 ...
2
votes
1
answer
2k
views
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 <...
4
votes
1
answer
2k
views
what does "ru_maxrss" means in getrusage
I compiled and run the following c++ code test.cpp on my macOS Sierra.
#include <iostream>
#include <sys/resource.h>
using namespace std;
int main() {
int a = 1;
struct rusage ...
0
votes
1
answer
109
views
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(...
2
votes
0
answers
474
views
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 ...
2
votes
2
answers
729
views
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 ...
0
votes
1
answer
716
views
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 ...
2
votes
2
answers
3k
views
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 ...
2
votes
1
answer
760
views
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",...
1
vote
1
answer
534
views
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() ...
2
votes
1
answer
757
views
/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 ...
0
votes
0
answers
170
views
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; ...
2
votes
2
answers
14k
views
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?
2
votes
1
answer
5k
views
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 ...
1
vote
1
answer
128
views
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 ...
3
votes
1
answer
13k
views
How getrusage works and What is really inside the rusage struct?
I'm trying to understand how
int getrusage(int who, struct rusage* usage)
works in order to calculate the running time of one my program. I red the man page, 10 times maybe, and still can't get it. ...
5
votes
1
answer
559
views
Are two successive calls to getrusage guaranteed to produce increasing results?
In a program that calls getrusage() twice in order to obtain the time of a task by subtraction, I have once seen an assertion, saying that the time of the task should be nonnegative, fail. This, of ...
2
votes
2
answers
2k
views
Check Internet Usage using JAVA
How can I Check upload and download data capacities using Java Code?
(in internet or local area network)
-1
votes
1
answer
299
views
C++ Object allocation and deallocation
Following program creates Objects in one loop and store the reference in vector for future deletion.
I am seeing an unusual behavior, even though the objects are deleting in the second iteration, ...
1
vote
1
answer
2k
views
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 ...
0
votes
2
answers
5k
views
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 ...
3
votes
1
answer
1k
views
Benchmark code - dividing by the number of iterations or not?
I had an interesting discussion with my friend about benchmarking a C/C++ code (or code, in general). We wrote a simple function which uses getrusage to measure cpu time for a given piece of code. (It ...
0
votes
1
answer
2k
views
Python getrusage with RUSAGE_CHILDREN behaves stangely?
Recently I have made a plan to develop a Online Judge system (like spoj). And I have write a judge script in python. It forks every time when it receives one submitted code, and then compile the code ...
19
votes
2
answers
15k
views
What's the unit of `ru_maxrss` on Linux?
This is from man getrusage
struct rusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
long ru_maxrss; /* maximum resident set ...
17
votes
3
answers
43k
views
Getting getrusage() to measure system time in C
I would like to measure the system time it takes to execute some code. To do this I know I would sandwich said code between two calls to getrusage(), but I get some unexpected results...
#include <...
2
votes
2
answers
1k
views
How can adding a header increase portability? (sys/time.h)
I just noticed this line in the getrusage man page:
Including <sys/time.h> is not required these days, but increases portability. (Indeed, struct timeval is defined in <sys/time.h>)
...
5
votes
1
answer
1k
views
getrusage vs. clock_gettime()
I am trying to obtain the CPU time consumed by a process on Ubuntu. As far as I know, there are two functions can do this job: getrusage() and clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp). In my ...
1
vote
2
answers
2k
views
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.
...
8
votes
1
answer
3k
views
Is getrusage broken in Linux (2.6.30)
This code
void print_usage(char * msg)
{
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
printf("Limits: %s\n", msg);
printf(" %s, %li\n", " maximum resident set size " ...
3
votes
1
answer
762
views
getrusage function on embedded linux
I have one bench marking application in which I am evaluating a C++ framework.
I am looking for the time and memory consumption. On linux, to get the memory occupied by the current program, I am ...
1
vote
2
answers
498
views
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 ...
0
votes
1
answer
665
views
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 ...
0
votes
1
answer
584
views
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 ...
1
vote
1
answer
2k
views
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 ...
23
votes
6
answers
85k
views
UNIX Programming. struct timeval how to print it (C-programming)
I am trying to print a value of type timeval. Actually I am able to print it, but I get the following warning:
Multiple markers at this line
format ‘%ld’ expects type ‘long int’, but argument 2 has ...