Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2692

Re: Not normal for the same program to be faster in C# than in C++ [Visual Studio 2019]

From "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Newsgroups comp.compilers
Subject Re: Not normal for the same program to be faster in C# than in C++ [Visual Studio 2019]
Date 2021-08-06 16:14 +0200
Organization Aioe.org NNTP Server
Message-ID <21-08-005@comp.compilers> (permalink)
References <21-08-001@comp.compilers> <21-08-003@comp.compilers>

Show all headers | View raw


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

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Not normal for the same program to be faster in C# than in C++ [Visual Studio 2019] Paolo Ferraresi <fp.box@alice.it> - 2021-08-05 18:24 +0000
  Re: Not normal for the same program to be faster in C# than in C++ [Visual Studio 2019] George Neuner <gneuner2@comcast.net> - 2021-08-05 22:58 -0400
    Re: Not normal for the same program to be faster in C# than in C++ [Visual Studio 2019] "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2021-08-06 16:14 +0200
      Re: Not normal for the same program to be faster in C# than in C++ [Visual Studio 2019] gah4 <gah4@u.washington.edu> - 2021-08-08 12:38 -0700

csiph-web