public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* time command does not show CPU time for MinGW binaries
@ 2018-01-07 16:02 daniel
  2018-01-07 18:40 ` arrl via cygwin
  0 siblings, 1 reply; 2+ messages in thread
From: daniel @ 2018-01-07 16:02 UTC (permalink / raw)
  To: cygwin

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
2.9.0(0.318/5/3)

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?

Daniel

--
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-07 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-07 16:02 time command does not show CPU time for MinGW binaries daniel
2018-01-07 18:40 ` arrl via cygwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).