BBC BASIC for Windows
« Yet another starfield »

Welcome Guest. Please Login or Register.
Apr 6th, 2018, 12:24am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Yet another starfield  (Read 1558 times)
rtr2
Guest
xx Re: Yet another starfield
« Reply #9 on: Apr 30th, 2015, 09:08am »

on Apr 28th, 2015, 9:30pm, David Williams wrote:
REM Division table needed for ARM BBC BASIC version
REM (using this is probably slower for BB4W)

I tried to benchmark that:

Code:
      DIM divTbl(40000)
      FOR I% = 1 TO 40000
        divTbl(I%) = 1/I%
      NEXT I%

      TIME = 0
      FOR J%=1 TO 100 : FOR I%=1 TO 40000 : A = divTbl(I%) : NEXT : NEXT
      PRINT "Using lookup table: ";TIME

      TIME = 0
      FOR J%=1 TO 100 : FOR I%=1 TO 40000 : A = 1/I% : NEXT : NEXT
      PRINT "Using division    : ";TIME 

Which gave (using BB4W v6.00a):

Code:
Using lookup table: 311
Using division    : 270 

So although the table is a little slower, there's not much in it.

Richard.
User IP Logged

David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
xx Re: Yet another starfield
« Reply #10 on: Apr 30th, 2015, 4:34pm »

on Apr 30th, 2015, 09:08am, g4bau wrote:
Which gave (using BB4W v6.00a):

Code:
Using lookup table: 311
Using division    : 270 

So although the table is a little slower, there's not much in it.


Thanks.

Going by ARM BBC BASIC on a Raspberry Pi 2, using a division table is, at best, about 34% faster (which surprised me - I thought it would be faster than that - perhaps upwards of 50%). At worst, if reading essentially random entries (5-byte floats) from a large division table (too big to fit in the CPU's L1 (or L2?) cache), it's only 1 or 2% faster. So, in real-world use I'm guessing around 20 to 25% faster on average.

For really speed-critical stuff, I've found that a division table of fixed-point integers to be worthwhile (with ARM BBC BASIC), when accuracy isn't too important.


David.
--
« Last Edit: Apr 30th, 2015, 7:27pm by David Williams » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls