Path: csiph.com!xmission!usenet.csail.mit.edu!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: "Dmitry A. Kazakov" Newsgroups: comp.compilers Subject: Re: Not normal for the same program to be faster in C# than in C++ [Visual Studio 2019] Date: Fri, 6 Aug 2021 16:14:22 +0200 Organization: Aioe.org NNTP Server Lines: 38 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <21-08-005@comp.compilers> References: <21-08-001@comp.compilers> <21-08-003@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="72327"; mail-complaints-to="abuse@iecc.com" Keywords: performance Posted-Date: 08 Aug 2021 11:14:14 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Content-Language: en-US Xref: csiph.com comp.compilers:2692 On 2021-08-06 04:58, George Neuner wrote: > I would modify your programs like so (in pseudo): > > total = 0 > allocate array > for N iterations > initialize array > start = current time > run the seive > stop = current time > total += (stop - start) > average = total / N Another technique is factoring out looping and other overheads by running empty loop as a reference: start = current time for N iterations initialize array run the sieve end loop; total1 = start - current time start = current time for N iterations initialize array end loop; total2 = start - current time average = (total1 - total2) / N -- sieve only P.S. Optimizations is a usual suspect of ruining benchmark measures. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de