Announcement

Collapse
No announcement yet.

An Old Benchmark

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

  • An Old Benchmark

    Hi,

    code placed bellow is an an old benchmark (100x Gammix). I have not PB/CC or PB/Win yet. Can you somebody try this code in PB/DOS, PB/CC and PB/Win (on same machine) for comparison? The same test in VB will welcome too. Please, specify results in sec and power of used computer. Thank beforehand.

    Lubos

    DIM A(100)
    DIM B(30)
    DEFINT I-L
    FOR I = 1 TO 100
    A(I) = I
    NEXT I
    FOR I = 1 TO 30
    B(I) = I
    NEXT I
    X = .12345
    BEGINTIME = TIMER
    FOR K = 1 TO 100
    FOR I = 1 TO 1000
    S = A(11)
    FOR J = 1 TO 10
    L = 11 - J
    S = S * X + A(L)
    NEXT J
    NEXT I
    FOR I = 1 TO 33
    S = 0
    FOR J = 1 TO 30
    S = S + A(J) * B(J)
    NEXT J
    NEXT I
    FOR I = 1 TO 667
    FOR J = 1 TO 30
    B(J) = A(J) + B(J)
    NEXT J
    NEXT I
    FOR I = 1 TO 1333
    S = X
    FOR J = 1 TO 5
    S = (S - X / S) * .5
    NEXT J
    NEXT I
    FOR I = 1 TO 67
    S = A(1)
    FOR J = 2 TO 100
    IF A(J) >= S THEN S = A(J)
    NEXT J
    NEXT I
    NEXT K
    DURATION = TIMER - BEGINTIME
    DURAT$ = STR$(DURATION)
    PRINT DURAT$
    Lubos
    A view on PowerBASIC

  • #2
    On a Dell Inspriron 530S, dual core, 1596mHz, 1G memory. Ran the program a couple of times on each compiler.
    Code:
    PB/Dos 3.5: .1101427
                    .1095622
    
    PB/CC 4.04: .093125
                     .093375
    
    PB/win 3.04: .093625
                      .093375
    Hope this answers your question.
    Last edited by Mel Bishop; 15 Mar 2008, 07:48 AM.
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      These are the best times and highest

      .016 - .018 for PB 8.04 and CC 4.04 both mark .016 at best
      .165 - .188 for PB DOS 3.5
      .375 - .567 for VB 6.0

      Fixed code up to drop in PBWIN or CC


      Code:
       
      #COMPILE EXE
      FUNCTION PBMAIN () AS LONG
          DIM A(100) AS INTEGER
          DIM B(30)  AS INTEGER
          DIM x AS LONG
          DIM i AS INTEGER
          DIM s AS INTEGER
          DIM k AS INTEGER
          DIM l AS INTEGER
          DIM j AS INTEGER
              'DEFINT I-L
              FOR I = 1 TO 100
                  A(I) = I
                   NEXT I
       
                  FOR I = 1 TO 30
                      B(I) = I
                       NEXT I
          X = .12345
       
          BEGINTIME# = TIMER
          FOR K = 1 TO 100
              FOR I = 1 TO 1000
                  S = A(11)
              FOR J = 1 TO 10
                  L = 11 - J
                  S = S * X + A(L)
                  NEXT J
                      NEXT I
              FOR I = 1 TO 33
                  S = 0
              FOR J = 1 TO 30
                  S = S + A(J) * B(J)
                     NEXT J
                      NEXT I
              FOR I = 1 TO 667
              FOR J = 1 TO 30
                  B(J) = A(J) + B(J)
                    NEXT J
                      NEXT I
              FOR I = 1 TO 1333
                  S = X
       
              FOR J = 1 TO 5
                  S = (S - X / S) * .5
                     NEXT J
                      NEXT I
       
              FOR I = 1 TO 67
                   S = A(1)
       
              FOR J = 2 TO 100
                  IF A(J) >= S THEN S = A(J)
                      NEXT J
                          NEXT I
                              NEXT K
       
          DURATION# = TIMER - BEGINTIME#
       
          DURAT$ = STR$(DURATION#)
       
       
          'Print DURAT$
          'MsgBox DURAT$
          'WAITKEY$
       
      END FUNCTION
      Last edited by Michael Mayerhoffer; 15 Mar 2008, 08:08 AM.
      A dozen what.

      Comment


      • #4
        Code:
        DIM A(100) AS INTEGER
            DIM B(30)  AS INTEGER
            DIM x AS LONG
            DIM i AS INTEGER
            DIM s AS INTEGER
            DIM k AS INTEGER
            DIM l AS INTEGER
            DIM j AS INTEGER
        Win/32 ===>
        Code:
            REGISTER i AS LONG, J AS LONG 
            DIM K AS LONG
            DIM A(30)  AS LONG
            DIM B(30)  AS LONG
            DIM x AS LONG
            DIM s AS LONG
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          FWIW no difference for INTEGER vs LONG on this. I tested both ways...was rather shocked. So I left them as Integers.
          A dozen what.

          Comment


          • #6
            Hi,

            observed improvement using REGISTER variables as Michael Matthias proposed is quite huge - 46ms vs 31ms on AMD Sempron 64bit, 3400+ ( but ticks on 1.8 GHz ).

            For k = 1000 the speed advantage grows a bit again: 484ms without registers or 297ms with registers.

            Tests were performed on PB/Win 8.04

            Also I would suggest to use GetTickCount or even better QueryPerformanceCounter for timing benchmarks, TIMER is good, but I trust the first two mentioned more.


            Bye,
            Petr
            Last edited by Petr Schreiber jr; 15 Mar 2008, 09:07 AM.
            [email protected]

            Comment


            • #7
              Code:
                  DIM A(100) AS INTEGER
                  DIM B(30)  AS INTEGER
                  DIM x AS LONG
                  DIM i AS INTEGER
                  DIM s AS INTEGER
                  DIM k AS INTEGER
                  DIM l AS INTEGER
                  DIM j AS INTEGER
              The original program uses SINGLEs for many of its variable, not INTEGERs.
              Code:
              DEFINT I-L
              All variables are SINGLE unless the name begins with a letter in the range I to L

              I get times of 650ms under PBDOS3.5 and 38ms in PBCC4.

              Paul.

              Comment


              • #8
                Thank to all

                Thank guys. Only a little note. Variables X, S, A() and B() are real type variables in original Gammix test (not integer).
                Lubos
                Lubos
                A view on PowerBASIC

                Comment


                • #9
                  Also I would suggest to use GetTickCount or even better QueryPerformanceCounter for timing benchmarks,
                  A. Programs like this - a bunch of 'do nothing' loops - are not 'benchmarks' of any sort.

                  B. Exercises like this - trying to move a program to both a new compiler and a new operating system without optimizing for either - are a waste of time at best and silly at worst.

                  C. The best compiler in the world is not going to change a mediocre programmer into a superstar.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Mr. Matthias,

                    A: The thread is marked as "An Old Benchmark", so the word seemed appropriate to me

                    B: ... or also can tell me if it is worth to purchase new version of compiler, even if PB/DOS on Windows (according to info from A View on PowerBASIC)is for most tasks enough? Here we get speed gain even with unoptimized version, isn't world looking nicer, birds singing cuter and everything just fantastic when realizing such a fact?

                    C: :bawling: ... and I was looking forward to paintbrush/artist


                    Best regards,
                    Petr

                    P.S. Why I posted this reaction, although it did not bring something super new to the discussion ... because:

                    ( orignally put on xkcd.com )
                    Last edited by Petr Schreiber jr; 15 Mar 2008, 03:02 PM.
                    [email protected]

                    Comment


                    • #11
                      Thank guys. Only a little note. Variables X, S, A() and B() are real type variables in original Gammix test (not integer).
                      I am not sure what "Real" means in PB, so I modified code to use SINGLE, DOUBLE or EXT.

                      Results again for PB/Win 8.04, Sempron 64bit 3400+ (1.8 GHz real )
                      Code:
                      [b]Real done as   Variable memory size  Time elapsed in [i]benchmark[/i] ;)[/b]
                      SINGLE          4B                    31 ms
                      DOUBLE          8B                    62 ms
                      EXT            10B                    94 ms
                      Lubos, one very nice feature in PB/Win - MACROs make changing variable data type a very simple process:
                      Code:
                      MACRO Real = SINGLE   
                      ...
                      ' -- Although PB does not know Real type, it will automatically use SINGLE now
                        DIM A(100) AS LOCAL Real
                        DIM B(30)  AS LOCAL Real
                        LOCAL x, s AS Real
                      So when I want to change all "real" variables to DOUBLE, I just change word in MACRO statement to
                      Code:
                      MACRO Real = DOUBLE
                      and so on...


                      Best regards,
                      Petr
                      [email protected]

                      Comment

                      Working...
                      X