VB compiler VS CS compiler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    VB compiler VS CS compiler

    I have recently moved from VB.NET to CS.NET to really learn the framework
    and see what happens in a real OOP world! I am too happy with this move,
    since it took me a very short time, to exploit CS as my new language of
    choice, leaving VB.NET only for some UI creation. This said, i should
    recommend that in spite of all words out there about the equality of these
    two languages (which also means their managed applications), i have seen
    much better performance in CS application than their VB.NET counter parts.
    This is a very strange thing to note, since the differences observed in
    performance were in pure arithmetic calculations, which had to be compiled
    to the same IL and JITted with the same JITting machine. My Experiment
    included a solution with the following VB and CS console applications:

    CS project - Console Application:

    /----------------------------------------------------------

    using System;
    class Class1
    {
    static void Main()
    {
    //Do the experiment three times
    double total =0;
    int cnt = 0;

    for (cnt = 0; cnt < 20; cnt++)
    {
    DateTime t1 = DateTime.Now;

    //The critical section:
    for(int i=0; i<10000000; i++)
    {
    for(int j=0; j<100; j++)
    {
    long y ;
    y = j;
    }
    }
    /////////////////////////////
    DateTime t2 = DateTime.Now;
    TimeSpan t = t2 - t1;
    Console.Write(" The operation took: {0}\n", t.TotalMillisec onds);
    total += t.TotalMillisec onds;
    }
    Console.WriteLi ne("\n--\nThe average time was: {0}\n", total / cnt);
    Console.ReadLin e();
    }
    }


    //-----------------------------------------
    CS properties:
    Release mode
    Optimize+
    No check for arithmetic overflows

    Average time took for critical operation: "2777.34375 " milliseconds

    *************** *************** ***********


    VB Project - Console Application

    '----------------------------------------------
    Option Strict On
    Option Explicit On

    Module Module1

    Sub Main()

    Dim total As Double = 0
    Dim cnt As Integer = 0

    For cnt = 0 To 20

    Dim t1 As DateTime = DateTime.Now

    ' The critical section
    For i As Integer = 0 To 10000000
    For j As Integer = 0 To 100
    Dim y As Long
    y = j
    Next
    Next
    ''''''''''''''' ''''''''''''
    Dim t2 As DateTime = DateTime.Now
    Dim t As TimeSpan = t2.op_Subtracti on(t2, t1)

    Console.WriteLi ne("The operation took {0}", t.TotalMillisec onds)
    total += t.TotalMillisec onds
    Next

    Console.WriteLi ne(vbCrLf & "The average time was: {0}", total / cnt)
    Console.ReadLin e()
    End Sub

    End Module


    '--------------------------
    VB project properties:

    Release Mode
    Optimize+
    No check for arithmetic overflows

    Average time took for critical operation: "3723.9583" milliseconds

    *************** *************** ****

    These tests were done on the following machine:
    CPU: Intel Celeron 2.40 GHz
    256 MB of RAM

    ..NET Framework 1.1
    VS 2003
    Win XP Pro SP2 with latest updates

    No virus scanning running


    Please tell me if i am wrong or sth. Otherwise please inform me what really
    causes this.

    Thanks in advance




  • Patrice

    #2
    Re: VB compiler VS CS compiler

    Check out the loops to make sure you are running the test the same number of
    times...

    --

    "Dave" <DavidWills1@ho tmail.com> a écrit dans le message de
    news:uelM0r5VFH A.2660@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I have recently moved from VB.NET to CS.NET to really learn the framework
    > and see what happens in a real OOP world! I am too happy with this move,
    > since it took me a very short time, to exploit CS as my new language of
    > choice, leaving VB.NET only for some UI creation. This said, i should
    > recommend that in spite of all words out there about the equality of these
    > two languages (which also means their managed applications), i have seen
    > much better performance in CS application than their VB.NET counter parts.
    > This is a very strange thing to note, since the differences observed in
    > performance were in pure arithmetic calculations, which had to be compiled
    > to the same IL and JITted with the same JITting machine. My Experiment
    > included a solution with the following VB and CS console applications:
    >
    > CS project - Console Application:
    >
    > /----------------------------------------------------------
    >
    > using System;
    > class Class1
    > {
    > static void Main()
    > {
    > //Do the experiment three times
    > double total =0;
    > int cnt = 0;
    >
    > for (cnt = 0; cnt < 20; cnt++)
    > {
    > DateTime t1 = DateTime.Now;
    >
    > //The critical section:
    > for(int i=0; i<10000000; i++)
    > {
    > for(int j=0; j<100; j++)
    > {
    > long y ;
    > y = j;
    > }
    > }
    > /////////////////////////////
    > DateTime t2 = DateTime.Now;
    > TimeSpan t = t2 - t1;
    > Console.Write(" The operation took: {0}\n", t.TotalMillisec onds);
    > total += t.TotalMillisec onds;
    > }
    > Console.WriteLi ne("\n--\nThe average time was: {0}\n", total / cnt);
    > Console.ReadLin e();
    > }
    > }
    >
    >
    > //-----------------------------------------
    > CS properties:
    > Release mode
    > Optimize+
    > No check for arithmetic overflows
    >
    > Average time took for critical operation: "2777.34375 " milliseconds
    >
    > *************** *************** ***********
    >
    >
    > VB Project - Console Application
    >
    > '----------------------------------------------
    > Option Strict On
    > Option Explicit On
    >
    > Module Module1
    >
    > Sub Main()
    >
    > Dim total As Double = 0
    > Dim cnt As Integer = 0
    >
    > For cnt = 0 To 20
    >
    > Dim t1 As DateTime = DateTime.Now
    >
    > ' The critical section
    > For i As Integer = 0 To 10000000
    > For j As Integer = 0 To 100
    > Dim y As Long
    > y = j
    > Next
    > Next
    > ''''''''''''''' ''''''''''''
    > Dim t2 As DateTime = DateTime.Now
    > Dim t As TimeSpan = t2.op_Subtracti on(t2, t1)
    >
    > Console.WriteLi ne("The operation took {0}",[/color]
    t.TotalMillisec onds)[color=blue]
    > total += t.TotalMillisec onds
    > Next
    >
    > Console.WriteLi ne(vbCrLf & "The average time was: {0}", total /[/color]
    cnt)[color=blue]
    > Console.ReadLin e()
    > End Sub
    >
    > End Module
    >
    >
    > '--------------------------
    > VB project properties:
    >
    > Release Mode
    > Optimize+
    > No check for arithmetic overflows
    >
    > Average time took for critical operation: "3723.9583" milliseconds
    >
    > *************** *************** ****
    >
    > These tests were done on the following machine:
    > CPU: Intel Celeron 2.40 GHz
    > 256 MB of RAM
    >
    > .NET Framework 1.1
    > VS 2003
    > Win XP Pro SP2 with latest updates
    >
    > No virus scanning running
    >
    >
    > Please tell me if i am wrong or sth. Otherwise please inform me what[/color]
    really[color=blue]
    > causes this.
    >
    > Thanks in advance
    >
    >
    >
    >[/color]


    Comment

    • Armin Zingler

      #3
      Re: VB compiler VS CS compiler

      "Dave" <DavidWills1@ho tmail.com> wrote
      [color=blue]
      > CS project - Console Application:
      > Average time took for critical operation: "2777.34375 " milliseconds[/color]

      [color=blue]
      > VB Project - Console Application
      > Average time took for critical operation: "3723.9583" milliseconds[/color]


      With same code and settings:

      C# version: 1605
      VB.Net: 1619

      (= equal)
      [color=blue]
      > CPU: Intel Celeron 2.40 GHz[/color]

      Glad to see that my results come from an 1,4GHz AMD (XP1600+) here.


      Did you choose "Start withouth debugging" from debug menu?

      Armin


      Comment

      • Steve Walker

        #4
        Re: VB compiler VS CS compiler

        In message <uelM0r5VFHA.26 60@TK2MSFTNGP10 .phx.gbl>, Dave
        <DavidWills1@ho tmail.com> writes[color=blue]
        >I have recently moved from VB.NET to CS.NET to really learn the framework
        >and see what happens in a real OOP world! I am too happy with this move,
        >since it took me a very short time, to exploit CS as my new language of
        >choice, leaving VB.NET only for some UI creation. This said, i should
        >recommend that in spite of all words out there about the equality of these
        >two languages (which also means their managed applications), i have seen
        >much better performance in CS application than their VB.NET counter parts.
        >This is a very strange thing to note, since the differences observed in
        >performance were in pure arithmetic calculations, which had to be compiled
        >to the same IL and JITted with the same JITting machine. My Experiment
        >included a solution with the following VB and CS console applications:[/color]

        I get:

        C#: 1090 ms
        VB: 1600 ms (with overflow checking)
        VB: 1100 ms (without overflow checking)

        Are you sure you had the "Remove integer overflow checks" box ticked?

        --
        Steve Walker

        Comment

        • Dave

          #5
          Re: VB compiler VS CS compiler

          Sorry! Seems like there was a problem with my VS
          I have reinstalled VS:

          Now the results are the same!
          CS: 934.375
          VB: 945.686

          If you like to experiment more, port the CS application to a managed Cpp
          application. The cool Cpp comiler seems to calculate the results in compile
          time, because the release Cpp.NET application is as fast as lightning!
          Try it....

          "Armin Zingler" <az.nospam@free net.de> wrote in message
          news:%23kAgU75V FHA.3620@TK2MSF TNGP09.phx.gbl. ..[color=blue]
          > "Dave" <DavidWills1@ho tmail.com> wrote
          >[color=green]
          >> CS project - Console Application:
          >> Average time took for critical operation: "2777.34375 " milliseconds[/color]
          >
          >[color=green]
          >> VB Project - Console Application
          >> Average time took for critical operation: "3723.9583" milliseconds[/color]
          >
          >
          > With same code and settings:
          >
          > C# version: 1605
          > VB.Net: 1619
          >
          > (= equal)
          >[color=green]
          >> CPU: Intel Celeron 2.40 GHz[/color]
          >
          > Glad to see that my results come from an 1,4GHz AMD (XP1600+) here.
          >
          >
          > Did you choose "Start withouth debugging" from debug menu?
          >
          > Armin
          >
          >[/color]





          Comment

          • Dave

            #6
            Re: VB compiler VS CS compiler

            Sorry! Seems like there was a problem with my VS
            I have reinstalled VS:

            Now the results are the same!
            CS: 934.375
            VB: 945.686

            If you like to experiment more, port the CS application to a managed Cpp
            application. The cool Cpp comiler seems to calculate the results in compile
            time, because the release Cpp.NET application is as fast as lightning!
            Try it....

            "Steve Walker" <steve@otolith. demon.co.uk> wrote in message
            news:mvBNu5L0UH hCFwMJ@otolith. demon.co.uk...[color=blue]
            > In message <uelM0r5VFHA.26 60@TK2MSFTNGP10 .phx.gbl>, Dave
            > <DavidWills1@ho tmail.com> writes[color=green]
            >>I have recently moved from VB.NET to CS.NET to really learn the framework
            >>and see what happens in a real OOP world! I am too happy with this move,
            >>since it took me a very short time, to exploit CS as my new language of
            >>choice, leaving VB.NET only for some UI creation. This said, i should
            >>recommend that in spite of all words out there about the equality of these
            >>two languages (which also means their managed applications), i have seen
            >>much better performance in CS application than their VB.NET counter parts.
            >>This is a very strange thing to note, since the differences observed in
            >>performance were in pure arithmetic calculations, which had to be compiled
            >>to the same IL and JITted with the same JITting machine. My Experiment
            >>included a solution with the following VB and CS console applications:[/color]
            >
            > I get:
            >
            > C#: 1090 ms
            > VB: 1600 ms (with overflow checking)
            > VB: 1100 ms (without overflow checking)
            >
            > Are you sure you had the "Remove integer overflow checks" box ticked?
            >
            > --
            > Steve Walker[/color]



            Comment

            • Larry Lard

              #7
              Re: VB compiler VS CS compiler



              Dave wrote:[color=blue]
              > Sorry! Seems like there was a problem with my VS
              > I have reinstalled VS:
              >
              > Now the results are the same!
              > CS: 934.375
              > VB: 945.686
              >
              > If you like to experiment more, port the CS application to a managed[/color]
              Cpp[color=blue]
              > application. The cool Cpp comiler seems to calculate the results in[/color]
              compile[color=blue]
              > time, because the release Cpp.NET application is as fast as[/color]
              lightning![color=blue]
              > Try it....
              >
              > "Armin Zingler" <az.nospam@free net.de> wrote in message
              > news:%23kAgU75V FHA.3620@TK2MSF TNGP09.phx.gbl. ..[color=green]
              > > "Dave" <DavidWills1@ho tmail.com> wrote
              > >[color=darkred]
              > >> CS project - Console Application:
              > >> Average time took for critical operation: "2777.34375 "[/color][/color][/color]
              milliseconds[color=blue][color=green]
              > >
              > >[color=darkred]
              > >> VB Project - Console Application
              > >> Average time took for critical operation: "3723.9583" milliseconds[/color]
              > >
              > >
              > > With same code and settings:
              > >
              > > C# version: 1605
              > > VB.Net: 1619
              > >
              > > (= equal)
              > >[color=darkred]
              > >> CPU: Intel Celeron 2.40 GHz[/color]
              > >
              > > Glad to see that my results come from an 1,4GHz AMD (XP1600+) here.
              > >
              > >
              > > Did you choose "Start withouth debugging" from debug menu?
              > >
              > > Armin
              > >
              > >[/color][/color]


              A good optimising compiler (I don't know enough to say if the C++.NET
              compiler is such a beast) might well optimise your entire test into a
              NOP, seeing as it doesn't actually do anything, and can be 'seen' to
              not actualy do anything.

              (pseudo-code)
              A thousand million times do this:
              Set a variable to a value, then throw away the variable

              --
              Larry Lard
              Replies to group please

              Comment

              • David Anton

                #8
                RE: VB compiler VS CS compiler

                By the way, your C# version was doing many extra iterations since each of
                your C# loops was cut short by 1 (this reduction in the outer loop alone
                means that your C# version was running 5% fewer iterations).

                i.e., "For cnt = 0 to 20" does 1 more iteration than "for (cnt = 0; cnt <
                20; cnt++)"

                David Anton
                Source code converters: Convert between C#, C++, Java, and VB with the most accurate and reliable source code converters

                Home of the Instant C# VB.NET to C# converter
                and the Instant VB C# to VB.NET converter

                "Dave" wrote:
                [color=blue]
                > I have recently moved from VB.NET to CS.NET to really learn the framework
                > and see what happens in a real OOP world! I am too happy with this move,
                > since it took me a very short time, to exploit CS as my new language of
                > choice, leaving VB.NET only for some UI creation. This said, i should
                > recommend that in spite of all words out there about the equality of these
                > two languages (which also means their managed applications), i have seen
                > much better performance in CS application than their VB.NET counter parts.
                > This is a very strange thing to note, since the differences observed in
                > performance were in pure arithmetic calculations, which had to be compiled
                > to the same IL and JITted with the same JITting machine. My Experiment
                > included a solution with the following VB and CS console applications:
                >
                > CS project - Console Application:
                >
                > /----------------------------------------------------------
                >
                > using System;
                > class Class1
                > {
                > static void Main()
                > {
                > //Do the experiment three times
                > double total =0;
                > int cnt = 0;
                >
                > for (cnt = 0; cnt < 20; cnt++)
                > {
                > DateTime t1 = DateTime.Now;
                >
                > //The critical section:
                > for(int i=0; i<10000000; i++)
                > {
                > for(int j=0; j<100; j++)
                > {
                > long y ;
                > y = j;
                > }
                > }
                > /////////////////////////////
                > DateTime t2 = DateTime.Now;
                > TimeSpan t = t2 - t1;
                > Console.Write(" The operation took: {0}\n", t.TotalMillisec onds);
                > total += t.TotalMillisec onds;
                > }
                > Console.WriteLi ne("\n--\nThe average time was: {0}\n", total / cnt);
                > Console.ReadLin e();
                > }
                > }
                >
                >
                > //-----------------------------------------
                > CS properties:
                > Release mode
                > Optimize+
                > No check for arithmetic overflows
                >
                > Average time took for critical operation: "2777.34375 " milliseconds
                >
                > *************** *************** ***********
                >
                >
                > VB Project - Console Application
                >
                > '----------------------------------------------
                > Option Strict On
                > Option Explicit On
                >
                > Module Module1
                >
                > Sub Main()
                >
                > Dim total As Double = 0
                > Dim cnt As Integer = 0
                >
                > For cnt = 0 To 20
                >
                > Dim t1 As DateTime = DateTime.Now
                >
                > ' The critical section
                > For i As Integer = 0 To 10000000
                > For j As Integer = 0 To 100
                > Dim y As Long
                > y = j
                > Next
                > Next
                > ''''''''''''''' ''''''''''''
                > Dim t2 As DateTime = DateTime.Now
                > Dim t As TimeSpan = t2.op_Subtracti on(t2, t1)
                >
                > Console.WriteLi ne("The operation took {0}", t.TotalMillisec onds)
                > total += t.TotalMillisec onds
                > Next
                >
                > Console.WriteLi ne(vbCrLf & "The average time was: {0}", total / cnt)
                > Console.ReadLin e()
                > End Sub
                >
                > End Module
                >
                >
                > '--------------------------
                > VB project properties:
                >
                > Release Mode
                > Optimize+
                > No check for arithmetic overflows
                >
                > Average time took for critical operation: "3723.9583" milliseconds
                >
                > *************** *************** ****
                >
                > These tests were done on the following machine:
                > CPU: Intel Celeron 2.40 GHz
                > 256 MB of RAM
                >
                > ..NET Framework 1.1
                > VS 2003
                > Win XP Pro SP2 with latest updates
                >
                > No virus scanning running
                >
                >
                > Please tell me if i am wrong or sth. Otherwise please inform me what really
                > causes this.
                >
                > Thanks in advance
                >
                >
                >
                >
                >[/color]

                Comment

                • David Anton

                  #9
                  RE: VB compiler VS CS compiler

                  Oops - I meant " your VB version was doing many extra iterations..."

                  "David Anton" wrote:
                  [color=blue]
                  > By the way, your C# version was doing many extra iterations since each of
                  > your C# loops was cut short by 1 (this reduction in the outer loop alone
                  > means that your C# version was running 5% fewer iterations).
                  >
                  > i.e., "For cnt = 0 to 20" does 1 more iteration than "for (cnt = 0; cnt <
                  > 20; cnt++)"
                  >
                  > David Anton
                  > www.tangiblesoftwaresolutions.com
                  > Home of the Instant C# VB.NET to C# converter
                  > and the Instant VB C# to VB.NET converter
                  >
                  > "Dave" wrote:
                  >[color=green]
                  > > I have recently moved from VB.NET to CS.NET to really learn the framework
                  > > and see what happens in a real OOP world! I am too happy with this move,
                  > > since it took me a very short time, to exploit CS as my new language of
                  > > choice, leaving VB.NET only for some UI creation. This said, i should
                  > > recommend that in spite of all words out there about the equality of these
                  > > two languages (which also means their managed applications), i have seen
                  > > much better performance in CS application than their VB.NET counter parts.
                  > > This is a very strange thing to note, since the differences observed in
                  > > performance were in pure arithmetic calculations, which had to be compiled
                  > > to the same IL and JITted with the same JITting machine. My Experiment
                  > > included a solution with the following VB and CS console applications:
                  > >
                  > > CS project - Console Application:
                  > >
                  > > /----------------------------------------------------------
                  > >
                  > > using System;
                  > > class Class1
                  > > {
                  > > static void Main()
                  > > {
                  > > //Do the experiment three times
                  > > double total =0;
                  > > int cnt = 0;
                  > >
                  > > for (cnt = 0; cnt < 20; cnt++)
                  > > {
                  > > DateTime t1 = DateTime.Now;
                  > >
                  > > //The critical section:
                  > > for(int i=0; i<10000000; i++)
                  > > {
                  > > for(int j=0; j<100; j++)
                  > > {
                  > > long y ;
                  > > y = j;
                  > > }
                  > > }
                  > > /////////////////////////////
                  > > DateTime t2 = DateTime.Now;
                  > > TimeSpan t = t2 - t1;
                  > > Console.Write(" The operation took: {0}\n", t.TotalMillisec onds);
                  > > total += t.TotalMillisec onds;
                  > > }
                  > > Console.WriteLi ne("\n--\nThe average time was: {0}\n", total / cnt);
                  > > Console.ReadLin e();
                  > > }
                  > > }
                  > >
                  > >
                  > > //-----------------------------------------
                  > > CS properties:
                  > > Release mode
                  > > Optimize+
                  > > No check for arithmetic overflows
                  > >
                  > > Average time took for critical operation: "2777.34375 " milliseconds
                  > >
                  > > *************** *************** ***********
                  > >
                  > >
                  > > VB Project - Console Application
                  > >
                  > > '----------------------------------------------
                  > > Option Strict On
                  > > Option Explicit On
                  > >
                  > > Module Module1
                  > >
                  > > Sub Main()
                  > >
                  > > Dim total As Double = 0
                  > > Dim cnt As Integer = 0
                  > >
                  > > For cnt = 0 To 20
                  > >
                  > > Dim t1 As DateTime = DateTime.Now
                  > >
                  > > ' The critical section
                  > > For i As Integer = 0 To 10000000
                  > > For j As Integer = 0 To 100
                  > > Dim y As Long
                  > > y = j
                  > > Next
                  > > Next
                  > > ''''''''''''''' ''''''''''''
                  > > Dim t2 As DateTime = DateTime.Now
                  > > Dim t As TimeSpan = t2.op_Subtracti on(t2, t1)
                  > >
                  > > Console.WriteLi ne("The operation took {0}", t.TotalMillisec onds)
                  > > total += t.TotalMillisec onds
                  > > Next
                  > >
                  > > Console.WriteLi ne(vbCrLf & "The average time was: {0}", total / cnt)
                  > > Console.ReadLin e()
                  > > End Sub
                  > >
                  > > End Module
                  > >
                  > >
                  > > '--------------------------
                  > > VB project properties:
                  > >
                  > > Release Mode
                  > > Optimize+
                  > > No check for arithmetic overflows
                  > >
                  > > Average time took for critical operation: "3723.9583" milliseconds
                  > >
                  > > *************** *************** ****
                  > >
                  > > These tests were done on the following machine:
                  > > CPU: Intel Celeron 2.40 GHz
                  > > 256 MB of RAM
                  > >
                  > > ..NET Framework 1.1
                  > > VS 2003
                  > > Win XP Pro SP2 with latest updates
                  > >
                  > > No virus scanning running
                  > >
                  > >
                  > > Please tell me if i am wrong or sth. Otherwise please inform me what really
                  > > causes this.
                  > >
                  > > Thanks in advance
                  > >
                  > >
                  > >
                  > >
                  > >[/color][/color]

                  Comment

                  • Nick Malik [Microsoft]

                    #10
                    Re: VB compiler VS CS compiler

                    One minor comment:
                    [color=blue]
                    >I have recently moved from VB.NET to CS.NET to really learn the framework
                    > and see what happens in a real OOP world![/color]

                    Object oriented programming is not a gift from a language. It starts with a
                    set of constructs and stretches into the fundamental approach you use when
                    creating code. VB.Net is an OOP language. So is C#.

                    In fact, the commercial OO modeling tools and code generators that I am
                    familiar with will generate code in Java, C++, C#, VB.Net, and Smalltalk. .
                    All of these languages are Object Oriented. (there are other OO languages
                    from what I understand, but I don't think many folks are using them).

                    --
                    --- Nick Malik [Microsoft]
                    MCSD, CFPS, Certified Scrummaster


                    Disclaimer: Opinions expressed in this forum are my own, and not
                    representative of my employer.
                    I do not answer questions on behalf of my employer. I'm just a
                    programmer helping programmers.
                    --
                    "Dave" <DavidWills1@ho tmail.com> wrote in message
                    news:uelM0r5VFH A.2660@TK2MSFTN GP10.phx.gbl...[color=blue]
                    >I have recently moved from VB.NET to CS.NET to really learn the framework
                    > and see what happens in a real OOP world! I am too happy with this move,
                    > since it took me a very short time, to exploit CS as my new language of
                    > choice, leaving VB.NET only for some UI creation. This said, i should
                    > recommend that in spite of all words out there about the equality of these
                    > two languages (which also means their managed applications), i have seen
                    > much better performance in CS application than their VB.NET counter parts.
                    > This is a very strange thing to note, since the differences observed in
                    > performance were in pure arithmetic calculations, which had to be compiled
                    > to the same IL and JITted with the same JITting machine. My Experiment
                    > included a solution with the following VB and CS console applications:
                    >
                    > CS project - Console Application:
                    >
                    > /----------------------------------------------------------
                    >
                    > using System;
                    > class Class1
                    > {
                    > static void Main()
                    > {
                    > //Do the experiment three times
                    > double total =0;
                    > int cnt = 0;
                    >
                    > for (cnt = 0; cnt < 20; cnt++)
                    > {
                    > DateTime t1 = DateTime.Now;
                    >
                    > //The critical section:
                    > for(int i=0; i<10000000; i++)
                    > {
                    > for(int j=0; j<100; j++)
                    > {
                    > long y ;
                    > y = j;
                    > }
                    > }
                    > /////////////////////////////
                    > DateTime t2 = DateTime.Now;
                    > TimeSpan t = t2 - t1;
                    > Console.Write(" The operation took: {0}\n", t.TotalMillisec onds);
                    > total += t.TotalMillisec onds;
                    > }
                    > Console.WriteLi ne("\n--\nThe average time was: {0}\n", total / cnt);
                    > Console.ReadLin e();
                    > }
                    > }
                    >
                    >
                    > //-----------------------------------------
                    > CS properties:
                    > Release mode
                    > Optimize+
                    > No check for arithmetic overflows
                    >
                    > Average time took for critical operation: "2777.34375 " milliseconds
                    >
                    > *************** *************** ***********
                    >
                    >
                    > VB Project - Console Application
                    >
                    > '----------------------------------------------
                    > Option Strict On
                    > Option Explicit On
                    >
                    > Module Module1
                    >
                    > Sub Main()
                    >
                    > Dim total As Double = 0
                    > Dim cnt As Integer = 0
                    >
                    > For cnt = 0 To 20
                    >
                    > Dim t1 As DateTime = DateTime.Now
                    >
                    > ' The critical section
                    > For i As Integer = 0 To 10000000
                    > For j As Integer = 0 To 100
                    > Dim y As Long
                    > y = j
                    > Next
                    > Next
                    > ''''''''''''''' ''''''''''''
                    > Dim t2 As DateTime = DateTime.Now
                    > Dim t As TimeSpan = t2.op_Subtracti on(t2, t1)
                    >
                    > Console.WriteLi ne("The operation took {0}",
                    > t.TotalMillisec onds)
                    > total += t.TotalMillisec onds
                    > Next
                    >
                    > Console.WriteLi ne(vbCrLf & "The average time was: {0}", total /
                    > cnt)
                    > Console.ReadLin e()
                    > End Sub
                    >
                    > End Module
                    >
                    >
                    > '--------------------------
                    > VB project properties:
                    >
                    > Release Mode
                    > Optimize+
                    > No check for arithmetic overflows
                    >
                    > Average time took for critical operation: "3723.9583" milliseconds
                    >
                    > *************** *************** ****
                    >
                    > These tests were done on the following machine:
                    > CPU: Intel Celeron 2.40 GHz
                    > 256 MB of RAM
                    >
                    > .NET Framework 1.1
                    > VS 2003
                    > Win XP Pro SP2 with latest updates
                    >
                    > No virus scanning running
                    >
                    >
                    > Please tell me if i am wrong or sth. Otherwise please inform me what
                    > really
                    > causes this.
                    >
                    > Thanks in advance
                    >
                    >
                    >
                    >[/color]


                    Comment

                    • _AnonCoward

                      #11
                      Re: VB compiler VS CS compiler


                      "Steve Walker" <steve@otolith. demon.co.uk> wrote in message
                      news:mvBNu5L0UH hCFwMJ@otolith. demon.co.uk...
                      :
                      : In message <uelM0r5VFHA.26 60@TK2MSFTNGP10 .phx.gbl>, Dave
                      : <DavidWills1@ho tmail.com> writes
                      : >I have recently moved from VB.NET to CS.NET to really learn the
                      : >framework and see what happens in a real OOP world! I am too happy
                      : >with this move, since it took me a very short time, to exploit CS
                      : >as my new language of choice, leaving VB.NET only for some UI
                      : >creation. This said, i should recommend that in spite of all words
                      : >out there about the equality of these two languages (which also means
                      : >their managed applications), i have seen much better performance in
                      : >CS application than their VB.NET counter parts. This is a very
                      : >strange thing to note, since the differences observed in performance
                      : >were in pure arithmetic calculations, which had to be compiled to the
                      : >same IL and JITted with the same JITting machine. My Experiment
                      : >included a solution with the following VB and CS console
                      : >applications :
                      :
                      : I get:
                      :
                      : C#: 1090 ms
                      : VB: 1600 ms (with overflow checking)
                      : VB: 1100 ms (without overflow checking)
                      :
                      : Are you sure you had the "Remove integer overflow checks" box ticked?
                      :
                      : --
                      : Steve Walker



                      That was my result as well. I compiled from the command line with the
                      following commands:

                      vbc /out:vb.exe tmp.vb
                      vbc /removeintchecks + /out:vb.exe tmp.vb

                      In the former, I saw response times of 1700 ms give or take. With the
                      checks off, I saw response times in the 1000+/- ms range.


                      I also tried the CS version with these commands:

                      csc /out:cs.exe tmp.cs
                      csc /checked+ /out:cs.exe tmp.cs

                      The results were similar.


                      Ralf


                      Comment

                      • _AnonCoward

                        #12
                        Re: VB compiler VS CS compiler


                        "Steve Walker" <steve@otolith. demon.co.uk> wrote in message
                        news:mvBNu5L0UH hCFwMJ@otolith. demon.co.uk...
                        :
                        : In message <uelM0r5VFHA.26 60@TK2MSFTNGP10 .phx.gbl>, Dave
                        : <DavidWills1@ho tmail.com> writes
                        : >I have recently moved from VB.NET to CS.NET to really learn the
                        : >framework and see what happens in a real OOP world! I am too happy
                        : >with this move, since it took me a very short time, to exploit CS
                        : >as my new language of choice, leaving VB.NET only for some UI
                        : >creation. This said, i should recommend that in spite of all words
                        : >out there about the equality of these two languages (which also means
                        : >their managed applications), i have seen much better performance in
                        : >CS application than their VB.NET counter parts. This is a very
                        : >strange thing to note, since the differences observed in performance
                        : >were in pure arithmetic calculations, which had to be compiled to the
                        : >same IL and JITted with the same JITting machine. My Experiment
                        : >included a solution with the following VB and CS console
                        applications:
                        :
                        : I get:
                        :
                        : C#: 1090 ms
                        : VB: 1600 ms (with overflow checking)
                        : VB: 1100 ms (without overflow checking)
                        :
                        : Are you sure you had the "Remove integer overflow checks" box ticked?
                        :
                        : --
                        : Steve Walker



                        That was my result as well. I compiled from the command line with the
                        following commands:

                        vbc /out:vb.exe tmp.vb
                        vbc /removeintchecks + /out:vb.exe tmp.vb

                        In the former, I saw response times of 1700 ms give or take. With the
                        checks off, I saw response times in the 1000+/- ms range.


                        I also tried the CS version with these commands:

                        csc /out:cs.exe tmp.cs
                        csc /checked+ /out:cs.exe tmp.cs

                        The results were similar.


                        Plz note that I changed the vb Module to a Class (and renamed Sub Main
                        to Public Shared Sub Main). I don't know if that made a difference, but
                        I wanted to make the two applications a similar as I could. In addition,
                        I increased the number of interations in the CS code as the [i = 0; i <
                        20; i++ ] block runs one fewer passes than [For i = 0 to 20]. That
                        mattered


                        While there are important differences between the two languages, I'm of
                        the opinion that for most situations the choice between which to use is
                        mostly a matter of personal taste.


                        Ralf





                        Comment

                        • _AnonCoward

                          #13
                          Re: VB compiler VS CS compiler


                          "Steve Walker" <steve@otolith. demon.co.uk> wrote in message
                          news:mvBNu5L0UH hCFwMJ@otolith. demon.co.uk...
                          :
                          : In message <uelM0r5VFHA.26 60@TK2MSFTNGP10 .phx.gbl>, Dave
                          : <DavidWills1@ho tmail.com> writes
                          : >I have recently moved from VB.NET to CS.NET to really learn the
                          : >framework and see what happens in a real OOP world! I am too happy
                          : >with this move, since it took me a very short time, to exploit CS
                          : >as my new language of choice, leaving VB.NET only for some UI
                          : >creation. This said, i should recommend that in spite of all words
                          : >out there about the equality of these two languages (which also means
                          : >their managed applications), i have seen much better performance in
                          : >CS application than their VB.NET counter parts. This is a very
                          : >strange thing to note, since the differences observed in performance
                          : >were in pure arithmetic calculations, which had to be compiled to the
                          : >same IL and JITted with the same JITting machine. My Experiment
                          : >included a solution with the following VB and CS console
                          applications:
                          :
                          : I get:
                          :
                          : C#: 1090 ms
                          : VB: 1600 ms (with overflow checking)
                          : VB: 1100 ms (without overflow checking)
                          :
                          : Are you sure you had the "Remove integer overflow checks" box ticked?
                          :
                          : --
                          : Steve Walker



                          That was my result as well. I compiled from the command line with the
                          following commands:

                          vbc /out:vb.exe tmp.vb
                          vbc /removeintchecks + /out:vb.exe tmp.vb

                          In the former, I saw response times of 1700 ms give or take. With the
                          checks off, I saw response times in the 1000+/- ms range.


                          I also tried the CS version with these commands:

                          csc /out:cs.exe tmp.cs
                          csc /checked+ /out:cs.exe tmp.cs

                          The results were similar.


                          Plz note that I changed the vb Module to a Class (and renamed Sub Main
                          to Public Shared Sub Main). I don't know if that made a difference, but
                          I wanted to make the two applications a similar as I could. In addition,
                          I increased the number of interations in the CS code as the [i = 0; i <
                          20; i++ ] block runs one fewer passes than [For i = 0 to 20]. That
                          mattered


                          While there are important differences between the two languages, I'm of
                          the opinion that for most situations the choice between which to use is
                          mostly a matter of personal taste.


                          Ralf





                          Comment

                          • Rob Windsor [MVP]

                            #14
                            Re: VB compiler VS CS compiler

                            I'm curious, what "real OOP" can you do in C# that can't be done in VB.NET?

                            --
                            Rob Windsor [MVP-VB]
                            G6 Consulting
                            Toronto, Canada



                            "Dave" <DavidWills1@ho tmail.com> wrote in message
                            news:uelM0r5VFH A.2660@TK2MSFTN GP10.phx.gbl...[color=blue]
                            >I have recently moved from VB.NET to CS.NET to really learn the framework
                            > and see what happens in a real OOP world! I am too happy with this move,
                            > since it took me a very short time, to exploit CS as my new language of
                            > choice, leaving VB.NET only for some UI creation. This said, i should
                            > recommend that in spite of all words out there about the equality of these
                            > two languages (which also means their managed applications), i have seen
                            > much better performance in CS application than their VB.NET counter parts.
                            > This is a very strange thing to note, since the differences observed in
                            > performance were in pure arithmetic calculations, which had to be compiled
                            > to the same IL and JITted with the same JITting machine. My Experiment
                            > included a solution with the following VB and CS console applications:
                            >
                            > CS project - Console Application:
                            >
                            > /----------------------------------------------------------
                            >
                            > using System;
                            > class Class1
                            > {
                            > static void Main()
                            > {
                            > //Do the experiment three times
                            > double total =0;
                            > int cnt = 0;
                            >
                            > for (cnt = 0; cnt < 20; cnt++)
                            > {
                            > DateTime t1 = DateTime.Now;
                            >
                            > //The critical section:
                            > for(int i=0; i<10000000; i++)
                            > {
                            > for(int j=0; j<100; j++)
                            > {
                            > long y ;
                            > y = j;
                            > }
                            > }
                            > /////////////////////////////
                            > DateTime t2 = DateTime.Now;
                            > TimeSpan t = t2 - t1;
                            > Console.Write(" The operation took: {0}\n", t.TotalMillisec onds);
                            > total += t.TotalMillisec onds;
                            > }
                            > Console.WriteLi ne("\n--\nThe average time was: {0}\n", total / cnt);
                            > Console.ReadLin e();
                            > }
                            > }
                            >
                            >
                            > //-----------------------------------------
                            > CS properties:
                            > Release mode
                            > Optimize+
                            > No check for arithmetic overflows
                            >
                            > Average time took for critical operation: "2777.34375 " milliseconds
                            >
                            > *************** *************** ***********
                            >
                            >
                            > VB Project - Console Application
                            >
                            > '----------------------------------------------
                            > Option Strict On
                            > Option Explicit On
                            >
                            > Module Module1
                            >
                            > Sub Main()
                            >
                            > Dim total As Double = 0
                            > Dim cnt As Integer = 0
                            >
                            > For cnt = 0 To 20
                            >
                            > Dim t1 As DateTime = DateTime.Now
                            >
                            > ' The critical section
                            > For i As Integer = 0 To 10000000
                            > For j As Integer = 0 To 100
                            > Dim y As Long
                            > y = j
                            > Next
                            > Next
                            > ''''''''''''''' ''''''''''''
                            > Dim t2 As DateTime = DateTime.Now
                            > Dim t As TimeSpan = t2.op_Subtracti on(t2, t1)
                            >
                            > Console.WriteLi ne("The operation took {0}",
                            > t.TotalMillisec onds)
                            > total += t.TotalMillisec onds
                            > Next
                            >
                            > Console.WriteLi ne(vbCrLf & "The average time was: {0}", total /
                            > cnt)
                            > Console.ReadLin e()
                            > End Sub
                            >
                            > End Module
                            >
                            >
                            > '--------------------------
                            > VB project properties:
                            >
                            > Release Mode
                            > Optimize+
                            > No check for arithmetic overflows
                            >
                            > Average time took for critical operation: "3723.9583" milliseconds
                            >
                            > *************** *************** ****
                            >
                            > These tests were done on the following machine:
                            > CPU: Intel Celeron 2.40 GHz
                            > 256 MB of RAM
                            >
                            > .NET Framework 1.1
                            > VS 2003
                            > Win XP Pro SP2 with latest updates
                            >
                            > No virus scanning running
                            >
                            >
                            > Please tell me if i am wrong or sth. Otherwise please inform me what
                            > really
                            > causes this.
                            >
                            > Thanks in advance
                            >
                            >
                            >
                            >[/color]


                            Comment

                            • Dave

                              #15
                              Re: VB compiler VS CS compiler

                              Well, you can declare types in an interface in VB.NET, while it generates an
                              error in CS. Sth like an abstract class in an interface "(Mustinher it" in
                              VB)....So, i think wheher CS or VB is doing sth wrong here.

                              "Rob Windsor [MVP]" <rob.windsor.no .spam@gmail.com > wrote in message
                              news:%23FZ2QX9V FHA.584@TK2MSFT NGP15.phx.gbl.. .[color=blue]
                              > I'm curious, what "real OOP" can you do in C# that can't be done in
                              > VB.NET?[/color]


                              Comment

                              Working...