I am having an issue with "gprof" while using WSL1 and "gcc" in Ubuntu. The only information it displays is the "calls" and anything else is set as 0.00. I do not think that is because the program is running too fast because when typing time ./go
it returns:
real = 0.569s; user = 0.547s; sys = 0.000s.
The main program (go.c) is:
#include <stdio.h>
#include "functions.h"
#define maxloop 1e7
int main(int argc, char*argv[]) {
int i;
double x;
double xsum = 0.0;
for (i = 1; i < maxloop; i ) {
x = myFun1(i) myFun2(i) myFun3(i);
xsum = x;
}
printf("xsum = %.6f\n", xsum);
return 0;
}
The file with the functions (functions.c) is:
#include <math.h>
double myFun1(double x) {
double a = sin(x);
return a;
}
double myFun2(double x){
double a = pow(x,3);
return a;
}
double myFun3(double x){
double a = sqrt(x);
return a;
}
The header (functions.h) is:
double myFun1(double x);
double myFun2(double x);
double myFun3(double x);
I am compiling in the terminal as:
gcc -pg -o go go.c functions.c -lm
Running the gprof as:
gprof ./go -p -b
CodePudding user response:
Upgrade to WSL2 for support of the profiling features required by gprof.