This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: time command does not show CPU time for MinGW binaries
- From: "arrl via cygwin" <cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Sun, 7 Jan 2018 13:34:03 -0500
- Subject: Re: time command does not show CPU time for MinGW binaries
- Authentication-results: sourceware.org; auth=none
- References: <7f12e332ab2678dec61d4f11f3112b94@poradnik-webmastera.com>
- Reply-to: tprince at intelretiree dot com
- Reply-to: arrl <n8tm at aol dot com>
On 1/7/2018 10:38 AM, daniel@poradnik-webmastera.com wrote:
> 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
>
I'd be surprised if a past or present cygwin could capture user or full
sys time from a .exe not linked against cygwin dll. clock() relies on
library code which is part of the .exe.
--
Tim Prince
--
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