Announcement

Collapse
No announcement yet.

Speed test

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Speed test

    Hi,

    I'm currently a VB.NET 2008 (Framework 3.5) user, but am seriously considering using PB as a second programming tool and on the long run as a replacement of VB.NET.

    To convince myself that that is a good thing to do I'm investigation PB's quality in several ways:
    • Reading through several threads in PB's forum.
    • Reading the newsgroups, although those aren't a great source regarding the longtime 'war' going on there between persons I will not mention .
    • Studying the online documentation of PB/Win9.


    On other thing I like to do now, and for which I need your help, is to test PB's speed, because that would be one of the main reasons I'm interested. As PB doesn't have a trial version I would kindly ask you to provide me with a compiled version of the code below (created with VB.NET):

    Code:
            'UInteger = unsigned 32-bit (4-byte)
            'Integer = signed 32-bit (4-byte)
            'Double = double-precision floating point number
    
            Dim StopWatch As New System.Diagnostics.Stopwatch()
            Dim strString As String = ""
            Dim dblDouble As Double = 0
    
            StopWatch.Start()
    
            For intIndex As UInteger = 0 To 100000
    
                strString = ""
                For intString As Integer = 0 To 200
                    strString = "ab" & strString & "de"
                Next
                strString = Replace(strString, "ab", "123")
    
                dblDouble = 9876.54321
                For intDouble As Integer = 0 To 1000
                    dblDouble *= dblDouble
                    dblDouble /= ((dblDouble + 100) / 2)
                Next
            Next
    
            MsgBox(StopWatch.ElapsedMilliseconds.ToString)
    On my PC this test, using a compiled EXE, runs between 11165-13066 milliseconds. These are the minimum and maximum times recorded on numerous executions. My PC: XP SP3, 4GB RAM, Intel Core 2 Duo T5870 @ 2.00Ghz.

    I certainly don't say that this is the greatest test ever made, but it will give me a clue on string and calculation operations. If you'll have better code examples (with compiled EXE's) I'll be very grateful to receive them from you.

    Second question:

    To be honest I think that VB.NET is a great programming language (also thanks to the huge framework) and VS2008 is a very comfortable IDE (especially the intellisense feature). On the other hand it can certainly be slow sometimes and sometimes the IDE eats 500MB of my memory.

    Besides the speed can you think of any more reasons to switch to PB?.

    Regards,
    Marc
    (once user of the great TurboBasic)

  • #2
    Code:
    #COMPILE EXE
    #OPTION VERSION5
    
    DECLARE FUNCTION GetTickCount LIB "KERNEL32.DLL" ALIAS "GetTickCount" () AS DWORD
    
    FUNCTION PBMAIN
        LOCAL strString AS STRING
        LOCAL nIndex, nString, nDouble AS LONG, dDouble AS DOUBLE, dwTick AS DWORD 
    
        dwTick = GetTickCount
    
        FOR nIndex = 0 TO 100000
    
            strString = ""
            FOR nString = 0 To 200
                strString = BUILD$("ab", strString, "de")
            NEXT
            REPLACE "ab" WITH "123" IN strString
    
            dDouble = 9876.54321
            FOR nDouble = 0 To 1000
                dDouble *= dDouble
                dDouble /= ((dDouble + 100) / 2)
            NEXT
        NEXT
    
        MsgBox "Ellapsed ticks" + STR$(GetTickCount - dwTick)
    END FUNCTION
    Result: 9313 ticks
    on a notebook dual core 2 duo running VISTA 64.bit
    Attached Files
    Patrice Terrier
    www.zapsolution.com
    www.objreader.com
    Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

    Comment


    • #3
      >As PB doesn't have a trial version

      AFAIK they still do. It's not really a 'trial' version, it's "the" version, for which you pay the regular price. But there is a thirty-day-no-questions asked money-back guarantee.

      At least that used to be the program. Contact PB's sales department to get official word.

      If you're not interested in that ......in both the Source Code Forum and the File Section, there are any number of posts where the poster has supplied not only the source code, but an executable as well. That might give you an idea of performance.

      I, too, have been using PB products starting with Turbo Basic. Don't sweat it, the compiler still generates extremely efficient code.

      (But as we all know, true performance does not come from hardware or software... it comes from the wetware... you know, that stuff between your ears?)

      MCM
      Last edited by Michael Mattias; 5 Sep 2009, 08:40 AM.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Iterative string concatenation like above, tho improved a lot by BUILD, is a notoriously slow technique to build up strings. VB.NET may not have the functions like PB to increase efficiency of code in situations like these and others, which is another reason you may like PB. Below I use the MID$ function to further double the speed over even BUILD.
        Code:
        #COMPILE EXE
        #DIM ALL
        
        DECLARE FUNCTION GetTickCount LIB "KERNEL32.DLL" ALIAS "GetTickCount" () AS DWORD
        
        FUNCTION PBMAIN
            LOCAL strString AS STRING
            LOCAL nString, nDouble AS LONG, dDouble AS DOUBLE, nIndex, dwTick AS DWORD
        
            dwTick = GetTickCount
        
            FOR nIndex = 0 TO 100000
        
                strString = STRING$(4 * 201, "x")
                FOR nString = 0 TO 200
                    MID$(strString, 2 * 201 - 2 * nString - 1) = "ab"
                    MID$(strString, 2 * 201 + 2 * nString + 1) = "de"
        '            strString = BUILD$("ab", strString, "de")
                NEXT
                REPLACE "ab" WITH "123" IN strString
        
                dDouble = 9876.54321
                FOR nDouble = 0 TO 1000
                    dDouble *= dDouble
                    dDouble /= ((dDouble + 100) / 2)
                NEXT
            NEXT
        
            MSGBOX "Ellapsed ticks" + STR$(GetTickCount - dwTick)
        END FUNCTION
        Attached Files

        Comment


        • #5
          The speed tests prove nothing - any compiler can optimize a loop (even VB6). PB's real power is in the finished result, which feels smoother and is a great deal smaller memory footprint than most. I have used almost all languages and nothing gives you the power of PB (except maybe straight "C", which is a painful write-only language). PB's syntax is easy to understand, using plain English words and structured if written by a seasoned programmer.

          Once you've learned the Windows API, programming in PB is a breeze, and of course we have this forum for any questions..
          kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

          Comment


          • #6
            > The speed tests [shown here] prove nothing...

            AMEN MY BROTHER!
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Kev,

              I agree with everything you have written

              ...
              Patrice Terrier
              www.zapsolution.com
              www.objreader.com
              Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

              Comment


              • #8
                Originally posted by Patrice Terrier View Post
                Result: 9313 ticks
                on a notebook dual core 2 duo running VISTA 64.bit
                Thx. I'm quite satisfied with the speed, on my PC 9219-10215 ms.

                Comment


                • #9
                  Originally posted by Michael Mattias View Post
                  >As PB doesn't have a trial version

                  AFAIK they still do. It's not really a 'trial' version, it's "the" version, for which you pay the regular price. But there is a thirty-day-no-questions asked money-back guarantee.

                  At least that used to be the program. Contact PB's sales department to get official word.

                  If you're not interested in that ......in both the Source Code Forum and the File Section, there are any number of posts where the poster has supplied not only the source code, but an executable as well. That might give you an idea of performance.

                  I, too, have been using PB products starting with Turbo Basic. Don't sweat it, the compiler still generates extremely efficient code.

                  (But as we all know, true performance does not come from hardware or software... it comes from the wetware... you know, that stuff between your ears?)

                  MCM
                  I know about the money-back guarantee, although it's not unconditional according to what I've read. Correct me if I'm wrong. I prefer not to spend shipping costs vica-versa if I can get some test result via this channel.

                  I know that this test doesn't say everything, it's only a small sign. Other things like database performance may be the bottleneck factor regarding speed and not the program itself.

                  Comment


                  • #10
                    Originally posted by John Gleason View Post
                    Iterative string concatenation like above, tho improved a lot by BUILD, is a notoriously slow technique to build up strings. VB.NET may not have the functions like PB to increase efficiency of code in situations like these and others, which is another reason you may like PB. Below I use the MID$ function to further double the speed over even BUILD.
                    Now that's impressive!: 6516-7250 ms.

                    NB: Funny thing is that the size of your EXE is exactly the same as Patrice's example: 9216 bytes. How's that possible?
                    Last edited by Marc van Breemen; 5 Sep 2009, 10:33 AM.

                    Comment


                    • #11
                      PureBasic ... OOPS!

                      Some guy suggested me to look at PureBasic, so I did. I'm totally new with PureBasic, so maybe I'm doing something wrong, but the time of PureBasic is: 29640-29844 ms!.

                      Below is the code I used in PureBasic. Maybe someone can optimize the code to give PureBasic a honest comparison (if possible). Right now it isn't an alternative (the language looks also much less mature).

                      Code:
                      StartTime = ElapsedMilliseconds()
                      
                      strString.s = ""
                      dblDouble.d = 0
                      intIndex.i = 0
                      intString.i = 0
                      intDouble.i = 0
                      
                      For intIndex.i = 0 To 100000
                      
                          strString.s = ""
                          For intString.i = 0 To 200
                              strString.s = "ab" + strString.s + "de"
                          Next intString.i
                          strString.s = ReplaceString(strString, "ab", "123")
                      
                          dblDouble.d = 9876.54321
                          For intDouble.i = 0 To 1000
                              dblDouble.d = dblDouble.d * dblDouble
                              dblDouble.d = dblDouble.d / ((dblDouble.d + 100) / 2)
                          Next intDouble.i
                      Next
                      
                      ElapsedTime = ElapsedMilliseconds()-StartTime 
                      
                      MessageRequester("","Tijd:" + Str(ElapsedTime), #PB_MessageRequester_Ok)

                      Comment


                      • #12
                        Originally posted by Kev Peel View Post
                        The speed tests prove nothing - any compiler can optimize a loop (even VB6). PB's real power is in the finished result, which feels smoother and is a great deal smaller memory footprint than most. I have used almost all languages and nothing gives you the power of PB (except maybe straight "C", which is a painful write-only language). PB's syntax is easy to understand, using plain English words and structured if written by a seasoned programmer.

                        Once you've learned the Windows API, programming in PB is a breeze, and of course we have this forum for any questions..
                        That sounds interesting.

                        In VB.NET some controls can be a little slow, like the LISTVIEW control. I'm talking about adding items and sorting. Does PB use the same controls or is it in PB different eg. faster/smoother?

                        Comment


                        • #13
                          I know about the money-back guarantee, although it's not unconditional according to what I've read. Correct me if I'm wrong
                          I am not now, have never been, nor am ever likely to be an employee, agent, officer or director of PowerBASIC Inc.

                          If you want corrrections or clarifications please contact [email protected].

                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Marc,
                            the following change knocks another 25% off the time in John's code above:
                            remove:
                            Code:
                            dDouble AS DOUBLE,
                            Add the line:
                            Code:
                            REGISTER dDouble AS EXT
                            It calculates more accurately than a double as it uses an 80bit extended FP value instead of a 52bit DOUBLE FP value (so may give slightly different results) but it stores dDouble in a register which runs faster.
                            9216 bytes. How's that possible?
                            9216 = 9 x 1k. If the block size on disk is 1k then any code between 8193 and 9216 bytes will occupy 9216 bytes on disk.


                            Paul.

                            Comment


                            • #15
                              Originally posted by Michael Mattias View Post
                              I am not now, have never been, nor am ever likely to be an employee, agent, officer or director of PowerBASIC Inc.

                              If you want corrrections or clarifications please contact [email protected].

                              MCM
                              Sorry if you misunderstood me.

                              I know you're not part of the PB staff and I certainly *not* intended to try changing the policy of PB just for my sake. I was just expressing what I've read.

                              Comment


                              • #16
                                Originally posted by Paul Dixon View Post
                                It calculates more accurately than a double as it uses an 80bit extended FP value instead of a 52bit DOUBLE FP value (so may give slightly different results) ....
                                I really not have a clue what you're saying there (yet) . But I'm sure in a while, after I've studied PB more, I will.
                                Last edited by Marc van Breemen; 5 Sep 2009, 10:59 AM.

                                Comment


                                • #17
                                  Marc,
                                  Maybe someone can optimize the code to give PureBasic a honest comparison
                                  You're more likely to get that at the PureBasic forum.

                                  Paul.

                                  Comment


                                  • #18
                                    Originally posted by Paul Dixon View Post
                                    Marc,

                                    You're more likely to get that at the PureBasic forum.

                                    Paul.
                                    I know, but I won't do that as I doubt that the results will improve that much to go beyond PowerBasic's results so far. Besides that I don't think PureBasic is mature enough language wise to see it as an alternative for VB.NET/PB.

                                    It's cheap (79 euro) with free updates "for life", which sounds better than PB but isn't. I don't think you can have a serious long standing business if you're practically give away your product like they do.

                                    Comment


                                    • #19
                                      Marc,
                                      I really not have a clue what you're saying hear (yet)
                                      Don't worry about it. Attched is a program with the one change mentioned so you can see if it is faster or not.

                                      Paul.
                                      Attached Files

                                      Comment


                                      • #20
                                        Marc,
                                        just a thought on the speed of your Purebasic example.
                                        If you're using the demo version then I think it might run with the debugger enabled at all times. For a fair speed comparrison you need to run with the debugger turned off.

                                        Paul.

                                        Comment

                                        Working...
                                        X