BASIC Speed Benchmark Tests

Author Message
Tinine
Guru Joined: 30/03/2016
Location: United Kingdom
Posts: 820
 Posted: 04:25am 01 Jan 2017

Happy New Year to all!

Just for giggles, I ran a similar BM on the ByPic which runs, interactively on the PIC32MX170 @40MHz. Not pure BASIC, though, so I had to adapt.

BM1: 0.001
BM2: 0.010
BM3: 0.023
BM4: 0.020
BM5: 0.027
BM6: 0.041
BM7: 0.080
BM8: 0.043

//ByPic Benchmark tests
//PIC32MX170 @40MHz

// No GOTO available so substituted a do-until
// No GOSUB available so substituted a function call "fourthou()" for "Gosub 4000"

// Created separate functions for each BM

dim j, timer, a, l#, s#, q

function bm1()
print "Benchmark 1\n"
j=0
timer = tick()

for j = 1 to 1000
next

print tick()-timer
endf
// Total execution time: 0.000968 (<1ms)

function bm2()
print "Benchmark 2\n"
j=0
timer = tick()

do
j=j+1
until j=1000

print tick()-timer
endf
// Total execution time: 0.0093 (<10ms)

function bm3()
print "Benchmark 3\n"
j=0
timer = tick()

do
j=j+1
a = j/j*j+j-j
until j=1000

print tick()-timer
endf
// Total execution time: 0.0231 (~23ms)

function bm4()
print "Benchmark 4\n"
j=0
timer = tick()

do
j=j+1
a = j/2*3+4-5
until j=1000

print tick()-timer
endf
// Total execution time: 0.0198 (<20ms)

function fourthou()
return 6
endf

function bm5()
print "Benchmark 5\n"
j=0
timer = tick()

do
j=j+1
a = fourthou()
a = j/2*3+4-5
until j=1000

print tick()-timer
endf
// Total execution time: 0.0273 (<28ms)

function bm6()
print "Benchmark 6\n"
j=0
timer = tick()

do
j=j+1
a = fourthou()
a = j/2*3+4-5
for q = 1 to 5
next
until j=1000

print tick()-timer
endf
// Total execution time: 0.0409 (~41ms)

function bm7()
print "Benchmark 7\n"
j=0
timer = tick()
dim ray2(6)
do
j=j+1
a = fourthou()
a = j/2*3+4-5
for q = 1 to 5
ray2(q) = a
next
until j=1000

print tick()-timer
endf
// Total execution time: 0.0803 (~80ms)

function bm8()
print "Benchmark 8\n"
j=0
timer = tick()

do
j=j+1
a = j^2
l# = log(j)
s# = sin(j)
until j=1000

print tick()-timer
endf
// Total execution time: 0.0432 (~43ms)