Thursday, August 30, 2007

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

Thursday, August 23, 2007

Tiny Basic v1.1 Released

I posted a new version of Tiny Basic in both the Run Basic and Liberty Basic wikispaces.

Here's a list of new features:
  1. Added a fixed array accessible from the interpreter -- a(1) to a(7001). The size of the array can be adjusted by changing the ArraySize variable in the code.
  2. Added the functions seconds and ms (or milliseconds) for benchmarking purposes.
  3. (LB4 only). Fixed LOAD and SAVE commands. The argument that these commands take is a number. For example, "LOAD 1". The file saved in the working directory will be "TinyBas1".
  4. (LB4 only). Fixed AutoRun feature. If a file exists in the working directory called "TinyBas0", it will load and run automatically when the interpreter starts up.
  5. (LB4 only). Added KILL and DIR commands to round out file management. KILL takes the same numeric argument as LOAD and SAVE. The DIR command has no arguments. It will display a list of Tiny Basic files and the time stamp.
Known Issues:

  • There is no file management for Run Basic yet. The file management code is commented out in the Run Basic version. The FILES command is still missing in Run Basic.
  • The seconds function does not work correctly. It will display milliseconds instead. This is a bug in version 2.27 of Run Basic that I haven't compensated for in the Tiny Basic code. This issue will be fixed in the near future.
  • There is a range checking bug when printing a value in an array. For example, if you type "PRINT a(7005)" and the array only goes up to 7001, then Liberty Basic will display a run-time error message. Range checking works properly, however, for assignment. This issue will be fixed in the near future.

Summary:

The goal of this release was to add enough features to run the Sieve benchmark. I will post the Tiny Basic Sieve program and the results of the benchmark in another post.

Wednesday, August 08, 2007

Tiny Basic tinkering

One of the examples on the Run Basic website is a port of Tiny Basic. It's fun to play with and is very much like the interactive, command line Basics found on early personal computers. In fact, I think Tiny Basic was the dialect used on the TRS-80 Model 1.

I'm currently working on modifying Tiny Basic to run the Sieve benchmark. Tiny Basic needs two things: profiling and array support.

I've already added profiling support for the RUN command. Tiny Basic now displays the running time of a program in milliseconds.

The last step is to add array support. Tiny Basic only supports the numeric variables 'a' to 'z'. I'm adding a single array to the environment in order to port the Sieve program. The array will be called a().

I will post the modified Tiny Basic code to the Run Basic Programming Wiki when finished. The whole point of this exercise, however, is to see how fast the Tiny Basic interpreter runs the Sieve benchmark and compare it to the others in the last post.