Author Topic: The integer Mandelbrot bench  (Read 13867 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #30 on: May 07, 2014, 07:35:34 AM »
Glad you're being lazy today!   8)

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #31 on: May 29, 2014, 02:53:56 PM »
I have been working with Android native Linux recently and thought I would run Ed's integer Mandelbrot benchmark on my Galaxy Tab 2 using C BASIC



Here is the same C BASIC program but running 64 bit on my Laptop.

jrs@laptop:~/C_BASIC/xlate$ time ./imandel
200574
60372774
120544974
180717174
240889374
301061574
309886830

real   0m2.028s
user   0m2.020s
sys   0m0.004s
jrs@laptop:~/C_BASIC/xlate$

Code: [Select]
#include <stdio.h>
#include "cbasic.h"

MAIN
BEGIN_FUNCTION
  DIM AS int left_edge, right_edge, top_edge, bottom_edge, max_iter,
             x_step, y_step, y0, x0, x, y, i, x_x, y_y, temp,
             the_char, accum, count;
  accum = 0;
  count = 0;
  DEF_WHILE (count < 1545)
  BEGIN_WHILE
    left_edge = -420;
    right_edge = 300;
    top_edge = 300;
    bottom_edge = -300;
    x_step = 7;
    y_step = 15;
    max_iter =  200;
    y0 = top_edge;
    DEF_WHILE (y0 > bottom_edge)
    BEGIN_WHILE
      x0 = left_edge;
      DEF_WHILE (x0 < right_edge)
      BEGIN_WHILE
        y = 0;
        x = 0;
        the_char = 32;
        x_x = 0;
        y_y = 0;
        i = 0;
        DEF_WHILE (i < max_iter AND x_x + y_y <= 800)
        BEGIN_WHILE
          x_x = (x * x) / 200;
          y_y = (y * y) / 200;
          IF (x_x + y_y > 800 ) THEN
            the_char = 48 + i;
            IF  (i > 9) THEN
              the_char = 64;
            END_IF
          ELSE
            temp = x_x - y_y + x0;
            IF ((x < 0 AND y > 0) OR (x > 0 AND y < 0)) THEN
              y = (-1 * ((-1 * (x * y)) / 100)) + y0;
            ELSE
              y = x * y / 100 + y0;
            END_IF
            x = temp;
          END_IF
          i = i + 1;
        WEND
        accum = accum + the_char;
        x0 = x0 + x_step;
      WEND
      y0 = y0 - y_step;
    WEND
    IF (count MOD 300 EQ 0) THEN_DO PRINT ("%d\n", accum);
    count = count + 1;
  WEND
  PRINT ("%d\n", accum);
  RETURN_FUNCTION(0);
END_FUNCTION

@Ed - You have Scriba (Script BASIC) noted as Pure (direct  text to execution) when in fact SB compiles/tokenized/PCode and syntax checks the program before execution starts. Scripts can be cached in their binary form for faster execution and load time.
« Last Edit: May 30, 2014, 04:31:36 PM by John »

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #32 on: June 04, 2014, 05:03:45 PM »
I was able to break the 2 second barrier running Ed's integer Mandelbrot on Koding.com. (FREE account )

Quote
What is Koding?

Koding is an online development environment with the goal of simplifying worldwide development and providing free computation and development to everyone. It does this by offering Free VMs for development to anyone. The Koding VMs provide you with a real Ubuntu OS, with areal Terminal, and allow you to work on real code. Python,PHP, C++, C, it doesn’t matter. Even better, they are online. Accessible from anywhere in the world. Even sharable with teams.

FYI: I canceled my Cloud9 IDE account.




« Last Edit: June 04, 2014, 10:53:57 PM by John »

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #33 on: May 11, 2015, 11:16:03 AM »
Hi Ed,

Thanks for the PM with a copy of your benchmark for SB. Sorry to say it runs forever. (assumed - I gave up after 13 minutes) Maybe it's a 64 bit issue or something else. I will give it a try on my XP VirtualBox and see it runs there.

Code: Script BASIC
  1. accum = 0
  2. count = 0
  3. while count < 1545
  4.     left_edge   = -420
  5.     right_edge  =  300
  6.     top_edge    =  300
  7.     bottom_edge = -300
  8.     x_step      =  7
  9.     y_step      =  15
  10.  
  11.     max_iter    =  200
  12.  
  13.     y0 = top_edge
  14.     while y0 > bottom_edge
  15.         x0 = left_edge
  16.         while x0 < right_edge
  17.             y = 0
  18.             x = 0
  19.             the_char = 32
  20.             x_x = 0
  21.             y_y = 0
  22.             i = 0
  23.             while i < max_iter and x_x + y_y <= 800
  24.                 x_x = (x * x) \ 200
  25.                 y_y = (y * y) \ 200
  26.                 if x_x + y_y > 800 then
  27.                     the_char = 48 + i
  28.                     if i > 9 then
  29.                         the_char = 64
  30.                     end if
  31.                 else
  32.                     temp = x_x - y_y + x0
  33.                     if (x < 0 and y > 0) or (x > 0 and y < 0) then
  34.                         y = (-1 * (-1 * x * y) \ 100) + y0
  35.                     else
  36.                         y = (x * y \ 100) + y0
  37.                     end if
  38.                     x = temp
  39.                 end if
  40.  
  41.                 i = i + 1
  42.             wend
  43.             accum = accum + the_char
  44.  
  45.             x0 = x0 + x_step
  46.         wend
  47.  
  48.         y0 = y0 - y_step
  49.     wend
  50.  
  51.     if count % 300 = 0 then
  52.         print accum, " "
  53.     end if
  54.  
  55.     count = count + 1
  56. wend
  57.  
  58. print accum
  59.  


jrs@laptop:~$ cd sb/sb22/test
jrs@laptop:~/sb/sb22/test$ time scriba edbench.sb
^C

real   13m19.104s
user   13m15.926s
sys   0m0.399s
jrs@laptop:~/sb/sb22/test$


Ed Davis

  • Guest
Re: The integer Mandelbrot bench
« Reply #34 on: May 11, 2015, 11:42:51 AM »
Hi Ed,

Thanks for the PM with a copy of your benchmark for SB. Sorry to say it runs forever. (assumed - I gave up after 13 minutes) Maybe it's a 64 bit issue or something else. I will give it a try on my XP VirtualBox and see it runs there.

Change the main loop counter of 1545 to 15, and see how long that takes.  Multiply that result time by 103, and you'll get an approximate idea of how long it will take to run the full test (e.g., with the loop counter at 1545).



JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #35 on: May 11, 2015, 12:18:02 PM »
Quote from: Ed Davis
Change the main loop counter of 1545 to 15 ...

Thanks Ed!

That would be just over 16 minutes on my laptop.  :'(

jrs@laptop:~/sb/sb22/test$ time scriba edbench.sb
200574 3008610
real   0m9.494s
user   0m9.442s
sys   0m0.028s
jrs@laptop:~/sb/sb22/test$

As a test to see if SB WHILE is a pig, I converted your benchmark to use IF/GOTO for the looping structure. No improvement I'm afraid.

Code: Script BASIC
  1. accum = 0
  2. count = 0
  3. W0:
  4. IF count < 15 THEN
  5. ' while count < 15
  6.    left_edge   = -420
  7.     right_edge  =  300
  8.     top_edge    =  300
  9.     bottom_edge = -300
  10.     x_step      =  7
  11.     y_step      =  15
  12.  
  13.     max_iter    =  200
  14.  
  15.     y0 = top_edge
  16. W1:
  17.     IF y0 > bottom_edge THEN
  18. '   while y0 > bottom_edge
  19.        x0 = left_edge
  20. W2:
  21.         IF x0 < right_edge THEN
  22. '       while x0 < right_edge
  23.            y = 0
  24.             x = 0
  25.             the_char = 32
  26.             x_x = 0
  27.             y_y = 0
  28.             i = 0
  29. W3:
  30.             IF i < max_iter and x_x + y_y <= 800 THEN
  31. '           while i < max_iter and x_x + y_y <= 800
  32.                x_x = (x * x) \ 200
  33.                 y_y = (y * y) \ 200
  34.                 if x_x + y_y > 800 then
  35.                     the_char = 48 + i
  36.                     if i > 9 then
  37.                         the_char = 64
  38.                     end if
  39.                 else
  40.                     temp = x_x - y_y + x0
  41.                     if (x < 0 and y > 0) or (x > 0 and y < 0) then
  42.                         y = (-1 * (-1 * x * y) \ 100) + y0
  43.                     else
  44.                         y = (x * y \ 100) + y0
  45.                     end if
  46.                     x = temp
  47.                 end if
  48.  
  49.                 i = i + 1
  50. '           wend
  51.            GOTO W3
  52.             END IF
  53.             accum = accum + the_char
  54.  
  55.             x0 = x0 + x_step
  56. '       wend
  57.        GOTO W2
  58.         END IF
  59.  
  60.         y0 = y0 - y_step
  61. '   wend
  62.    GOTO W1
  63.     END IF
  64.  
  65.     if count % 300 = 0 then
  66.         print accum, " "
  67.     end if
  68.  
  69.     count = count + 1
  70. ' wend
  71. GOTO W0
  72. END IF
  73. print accum
  74.  


jrs@laptop:~/sb/sb22/test$ time scriba edbench4.sb
200574 3008610
real   0m9.680s
user   0m9.662s
sys   0m0.000s
jrs@laptop:~/sb/sb22/test$

« Last Edit: May 11, 2015, 12:37:30 PM by John »