C++ vs. C# vs. Assembly Language

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael A. Covington

    #16
    Re: C++ vs. C# vs. Assembly Language


    "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
    news:MPG.19f6d1 d6370e16a598988 8@msnews.micros oft.com...[color=blue]
    > Jason Smith <jason@nospam.c om> wrote:[color=green]
    > > Some numbers:
    > >
    > > I've been playing around with a program for solving the Rubik's Cube[/color][/color]
    using[color=blue][color=green]
    > > brute force. I wrote it in Java, C# using safe code, and C# using[/color][/color]
    pointers,[color=blue][color=green]
    > > each one faster than the last.
    > >
    > > C# using pointers: 6x
    > > C# using safe code: 3x
    > > Java (Sun 1.4) using code optimized for speed: 1x
    > >
    > > I haven't written it in C/C++, but seeing how much faster it is than Sun
    > > Java for this particular task, I have to think it is getting in the same
    > > ballpark.[/color]
    >
    > I'd be interested to see the code you're using there - C# and Java are
    > roughly the same speed in tests I've done. C# certainly isn't 3 times
    > as fast "in general".[/color]

    How about Prolog? If you want fast brute-force searches...





    Comment

    • Anthony Berglas

      #17
      Re: C++ vs. C# vs. Assembly Language

      Did you use the sever optimized Java? In my tests it is substantially
      faster than .Net. (The default client Java was slower than .Net, I wonder
      why they still ship both.) Also in my test Java beat C++ because it did
      some clever inlining.

      It would be interesting to get some idea as to why you see the differences.

      Anthony

      "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
      news:MPG.19f6d1 d6370e16a598988 8@msnews.micros oft.com...[color=blue]
      > Jason Smith <jason@nospam.c om> wrote:[color=green]
      > > Some numbers:
      > >
      > > I've been playing around with a program for solving the Rubik's Cube[/color][/color]
      using[color=blue][color=green]
      > > brute force. I wrote it in Java, C# using safe code, and C# using[/color][/color]
      pointers,[color=blue][color=green]
      > > each one faster than the last.
      > >
      > > C# using pointers: 6x
      > > C# using safe code: 3x
      > > Java (Sun 1.4) using code optimized for speed: 1x
      > >
      > > I haven't written it in C/C++, but seeing how much faster it is than Sun
      > > Java for this particular task, I have to think it is getting in the same
      > > ballpark.[/color]
      >
      > I'd be interested to see the code you're using there - C# and Java are
      > roughly the same speed in tests I've done. C# certainly isn't 3 times
      > as fast "in general".
      >
      > --
      > Jon Skeet - <skeet@pobox.co m>
      > http://www.pobox.com/~skeet
      > If replying to the group, please do not mail me too[/color]


      Comment

      • Jon Skeet [C# MVP]

        #18
        Re: C++ vs. C# vs. Assembly Language

        <"Anthony Berglas" <aberglas at frontsys (a spam free .com)>> wrote:[color=blue]
        > Did you use the sever optimized Java? In my tests it is substantially
        > faster than .Net. (The default client Java was slower than .Net, I wonder
        > why they still ship both.)[/color]

        The client JVM starts up faster and is generally better for short-
        running processes. The server JVM is generally better for long-running
        processes.
        [color=blue]
        > Also in my test Java beat C++ because it did
        > some clever inlining.
        >
        > It would be interesting to get some idea as to why you see the differences.[/color]

        It really depends on exactly what you're doing. For some operations,
        the .NET JIT will beat the HotSpot JIT hands down - and for some
        operations, the reverse is true. They have some pretty radically
        different assumptions, to start with - HotSpot will progressively JIT
        with more and more optimisations as it sees one section of code being
        used more and more, whereas the .NET JIT is a "one off" JIT. Sometimes
        one way works better, sometimes the other does.

        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        Working...