Run BASIC vs. Just BASIC

new BookmarkLockedFalling
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 13, 2013 10:05:19 GMT -5

  • I compared the speed of my programs for simple mathematical calculations, running under RunBASIC and JustBASIC. Although RunBASIC has limitations, for example in an amount of generated numbers (eg prime numbers), then the speed of its operation is much greater than JustBASIC, and comparable to the speed of the analogous calculations carried out in FreeBASIC.
  • Another thing is probably simpler syntax of graphics programs written for RunBASIC than a JustBASIC.
  • Third, the differences in the operation of GOTO to break the loop. This break works fine in the similar programs running in RunBASIC and FreeBASIC, but does not work in JustBASIC. Weird, isn't it?
See the following code with mentioned GOTO in line if p / q = int (p / q) then goto [nextp] in the program for calculation of prime numbers.
input "Enter the limit "; n
print "Prime numbers: "

for p = 2 to n
'or sqr(p) for faster calculations
for q = 2 to p - 1
'or (p mod q = 0)
if p / q = int(p / q) then goto [nextp]
next q

print p; " ";
[nextp]
next p

end
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 13, 2013 16:46:15 GMT -5

In other dialects of BASIC there are commands counting the number of seconds since specific time in the past. Below there are two examples of programs computing time of 200000000 iterations of a floating point operation. For PureBasic this time is about 1.8 sec, and for FreeBASIC about 3.3 sec on ​​my computer. I would like to do the same for RunBASIC, but I think there is no suitable command? I checked helps, but it was not there.
;PureBasic

OpenConsole()
x.d
y.d
ElapsedTime.d
i.i

StartTime = ElapsedMilliseconds()

x = 1
y = 1.00000001

For i = 1 To 200000000
x = x * y
Next i

ElapsedTime = ElapsedMilliseconds() - StartTime
Print(Str(ElapsedTime))

Repeat

Until Inkey() <> ""
CloseConsole()
'FreeBASIC

Dim As Double x, y, StartTime
Dim As Integer i

StartTime = Timer

x = 1
y = 1.00000001

For i = 1 To 200000000
x = x * y
Next i

Print Timer - StartTime

Sleep
Last Edit: Aug 13, 2013 16:52:07 GMT -5 by krzysztof
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Post by StefanPendl on Aug 13, 2013 23:41:51 GMT -5

krzysztof Avatar
I would like to do the same for RunBASIC, but I think there is no suitable command? I checked helps, but it was not there.


See time$("seconds") in the functions section of the help file.

In addition the help file on the Run BASIC web site is the one for the Run BASIC web site, which uses an older version of Run BASIC.
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 14, 2013 4:41:21 GMT -5

Thank You very much for Your help. In fact, I'm blind ;) and I need to buy stronger glasses or stop to sit on the programs at night. In the helps of JustBASIC there is even sample program that calculates the time of counting of such loop!
Because of the reasonable period of time to calculate the loop, I had to reduce the number of iterations by a factor of 10. Estimated results are listed below, but be aware that FreeBASIC and PureBASIC are compilers and therefore perform the cycle much faster!

For i = 1 To 10000000 (reduced value)

Time:

Run BASIC 6.3 - 8 sec
Just BASIC 49 - 53.5 sec
Liberty BASIC about 49 sec
Pure BASIC pure 0.09 - 0.17 sec
Free BASIC 0.16 - 0.23 sec

Note that speed of RunBASIC is much higher than Just/Liberty BASIC.
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Sept 7, 2013 5:04:43 GMT -5

I have briefly compared RunBASIC and JustBASIC, and for me RB is nicer than JB. Codes for simple maths looks the same, but for graphics differs much. RB and its helps allow to quickly write simple program for drawing special pixels for instance Mandelbrot set, but JB's syntax and its support are more complicated and not clear.
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Sept 7, 2013 11:22:03 GMT -5

The graphic codes written for RunBASIC are simple and clear. See the example
graphic #Sierpinski, 200, 200

for x = 0 to 127
for y = 0 to 127
if (x and y) = 0 then #Sierpinski set(x, y)
next y
next x

render #Sierpinski
end
and compare with similar code written in PureBASIC
Define.u x, y

If OpenWindow(0, 0, 0, 512, 512, "Sierpinski", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

If CreateImage(0, 512, 512)

If StartDrawing(ImageOutput(0))

For x = 0 To 511

For y = 0 To 511

If x & y = 0
Plot(x, y, RGB(0, 0, 0))
Else
Plot(x, y, RGB(255, 255, 255))
EndIf

Next y

Next x
StopDrawing()
EndIf

EndIf

ImageGadget(0, 0, 0, 512, 512, ImageID(0))

Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
End
That one is horrible, isn't it? Both do the same - print the Sierpinski triangle. Other examples are for instance, input and print commands. In RunBASIC everything is clear and natural:
input n
print n
but not in PureBASIC:
n = Val(Input())
Print(Str(n))
Not enough? In RunBASIC
for i = 1 to 10 step 0.1
works fine, but not in PureBASIC - step has to be integer.