I was trying to use top to monitor the performance of my codes in c, but when I run the program does not appear. Is it there just not visible, or can not monitor c-codes using the top? What should I use to monitor if the top does not work? The code is this:
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/stat.h>
int main(){
struct stat info;
pid_t id, filho;
struct timeval tv1, tv2;
double t1, t2;
id = getpid();
printf("Processo %ld \n", (long)id);
gettimeofday(&tv1, NULL);
lstat("teste", &info);
gettimeofday(&tv2, NULL);
t1 = (double)(tv1.tv_sec) + (double)(tv1.tv_usec)/ 1000000.00;
t2 = (double)(tv2.tv_sec) + (double)(tv2.tv_usec)/ 1000000.00;
printf("\nO tempo de execucao foi %lf\n", (t2 - t1));
_exit(0);
}
I use gcc -o dados dados.c
to compile the file. E ./dados
to run on terminal. In the code itself it shows the pid of it and when I go looking in ps, I can not find.