From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76082 invoked by alias); 7 Jan 2018 18:40:23 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 76070 invoked by uid 89); 7 Jan 2018 18:40:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_MXURI,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=prince, Prince, H*F:D*aol.com, UD:mx.aol.com X-HELO: omr-m020e.mx.aol.com Received: from omr-m020e.mx.aol.com (HELO omr-m020e.mx.aol.com) (204.29.186.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 07 Jan 2018 18:40:22 +0000 Received: from mtaout-mbc01.mx.aol.com (mtaout-mbc01.mx.aol.com [172.26.221.141]) by omr-m020e.mx.aol.com (Outbound Mail Relay) with ESMTP id 8C3FD3800043 for ; Sun, 7 Jan 2018 13:40:19 -0500 (EST) Received: from [192.168.0.4] (unknown [65.189.93.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mtaout-mbc01.mx.aol.com (MUA/Third Party Client Interface) with ESMTPSA id 44E9038000083 for ; Sun, 7 Jan 2018 13:40:19 -0500 (EST) Reply-To: tprince@intelretiree.com Subject: Re: time command does not show CPU time for MinGW binaries To: cygwin@cygwin.com References: <7f12e332ab2678dec61d4f11f3112b94@poradnik-webmastera.com> From: "arrl via cygwin" Reply-To: arrl Message-ID: <22fec84a-26de-5bbd-4e49-5337cd8aedc4@aol.com> Date: Sun, 07 Jan 2018 18:40:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <7f12e332ab2678dec61d4f11f3112b94@poradnik-webmastera.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit x-aol-global-disposition: G x-aol-sid: 3039ac1add8d5a5269934459 X-AOL-IP: 65.189.93.33 X-SW-Source: 2018-01/txt/msg00052.txt.bz2 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 > #include > > #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