Skip to main content

Tiny Basic Sieve Benchmark

Compared to the Sieve benchmarks in previous posts, Tiny Basic is very slow. In fact, it's much slower than I anticipated.

I ran Tiny Basic on both the Run Basic public server and Liberty Basic 4.03 on my laptop. Here are the numbers:



After 5000, the Run Basic program exceeded the allowable time on the public server.

The following is the Sieve program. I had to use IF statements because Tiny Basic doesn't have a FOR/NEXT loop yet.

10 REM sieve2

20 REM ported to Tiny Basic from Liberty Basic by David den Haring

30 REM last updated: 8-14-07

40 REM s -- size, a() -- flags array, a -- start time, z -- end time

50 REM i -- loop counter, p -- prime, c -- prime count, k -- temp

60 s = 7000 : i = 1

70 a = ms

80 IF a(i) > 0 THEN GOTO 300

90 p = (i + i + 3)

100 k = i + p

110 IF k > s THEN GOTO 290

120 a(k) = 1

130 k = k + p

140 GOTO 110

290 c = c + 1

300 i = i + 1

310 IF i > s THEN GOTO 400

320 GOTO 80

400 z = ms

410 PRINT c;

420 PRINT " primes found."

430 PRINT "End of iteration. Elapsed time in milliseconds: ";

440 PRINT z - a

450 END

Comments

Popular posts from this blog

Run BASIC Hosting Service Launched

The new Run BASIC hosting service launched at midnight! Please visit http://runbasichosting.com for more details. Monthly and annual subscriptions are available. Run BASIC , a product by ShopTalk Systems, is a tool that makes it easy to create your own web applications. No computer science degree required . Run BASIC Hosting is a service that makes it easy to deploy your applications to the Internet. No IT experience required .

Hammurabi (on Run Basic)

To celebrate 50+ years of BASIC, I've published an early version of the classic simulation, Hammurabi, on the Run Basic Hosting site. It ran "almost" unchanged -- line numbers, GOTOs and all. I'll publish the tweaked Run Basic code later, but here is the link to the game if you want to try it out right away. If you're interested in the original source, here is a nice article on the game at the Atari Archives. Have fun!
Liberty Basic 4 is now in Alpha testing. It looks like it's going to be a big step forward for the language. Here's a brief list of the new features: True global variables. (declared using the new global keyword) Passing arguments to a sub or function by reference. (I complained about the lack of this feature in LB3 about 4 posts ago.) Handle variables and the new maphandle command. (liberation from static handles to windows, controls and files) Dynamic evaluation of Liberty Basic code inside of a running program. ( eval returns a numeric value and eval$ returns a string value) Subroutines can now be used for event handlers. (a better choice over branch labels for large programs) There are many other enhancements, but these are the big ones. The IDE also has a new feature that lets you create tutorials or lessons using a three-pane window. On the left pane is the outline of the lesson. On the upper right pane is the lesson text. On the lower right pane is LB code...