public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: daniel@poradnik-webmastera.com
To: cygwin@cygwin.com
Subject: time command does not show CPU time for MinGW binaries
Date: Sun, 07 Jan 2018 16:02:00 -0000	[thread overview]
Message-ID: <7f12e332ab2678dec61d4f11f3112b94@poradnik-webmastera.com> (raw)

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

             reply	other threads:[~2018-01-07 16:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-07 16:02 daniel [this message]
2018-01-07 18:40 ` arrl via cygwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f12e332ab2678dec61d4f11f3112b94@poradnik-webmastera.com \
    --to=daniel@poradnik-webmastera.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).