Memory error. Highlighting ...

I am trying to use the gprof: command gprof -s executable.exe gmon.out gmon.sumto combine the profiling data collected from two runs of my programs. But the following error appears:

gprof: 340,320,7348 bytes are allocated from memory after a total of 196,608 bytes

My program is pretty simple (just one loop for). If I run it once, the runtime is too short (it shows 0.00s) for the gprof entry.

In CygWin, I do the following steps:

  • gcc -pg -o fl forAndWhilLoop.c

  • fl (run the program)

  • mv gmon.out gmon.sum

  • fl (run the program)

  • gprof -s fl.exe gmon.out gmon.sum

  • gprof fl.exe gmon.sum> gmon.out

  • gprof fl.exe

My program:

int main(void)
{
    int fac=1;
    int count=10;
    int k;

    for(k=1;k<=count;k++)
    {
        fac = fac * k;
    }

    return 0;
}

So can someone help me with this problem? Thank!

+3
source share
1

, , , 105ns. :

void forloop(void){ 
    int fac=1; 
    int count=10; 
    int k; 

    for(k=1;k<=count;k++) 
    { 
        fac = fac * k; 
    } 
} 

int main(int argc, char* argv[])
{
    int i;
    for (i = 0; i < 1000000000; i++){
        forloop();
    }
    return 0;
}

? . 10 ^ 9 , = .

92ns;

int k = 1;
while(k+5 <= count){
    fac *= k * (k+1) * (k+2) * (k+3) * (k+4);
    k += 5;
}
while(k <= count){
    fac *= k++;
}

Release Debug 21ns. , .

0

Source: https://habr.com/ru/post/1730841/


All Articles