Web lists-archives.com

time command does not show CPU time for MinGW binaries

time command does not show CPU time for MinGW binaries. I have this sample piece of code:

#include <stdio.h>
#include <time.h>

#define N 100000
#define K 10000

double data[N];

int main()
    clock_t t = clock();
    for (unsigned long n = 0; n < N; ++n)
        for (unsigned long k = 0; k < K; ++k)
            data[n] += data[n] * data[k];

    t = clock() - t;
    printf("Time %.3f\n", (double)t / CLOCKS_PER_SEC);

    return 0;

When I compile it using Cygwin's gcc, time shows CPU time (user time) as expected:

$ gcc -o test test.c -O3
$ time ./test
Time 1.890

real    0m2,043s
user    0m1,890s
sys     0m0,000s

However when code is compiled using MinGW's gcc, time reports 0.000 as a user time. Note that clock() function still provides valid values:

$ x86_64-w64-mingw32-gcc -o test test.c -O3
$ time ./test
Time 1.889

real    0m1,998s
user    0m0,000s
sys     0m0,015s

I have updated Cygwin to latest version today.
$ uname -r

gcc (GCC) 6.4.0
x86_64-w64-mingw32-gcc (GCC) 6.4.0

I am using Win10 Pro now. As I recall, it worked when I was using it about year ago on Win7 Pro. So it is probably Win10 issue.

Is this a known bug, or should I log a new one? Do you know if there is any workaround?


Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple