|
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
|
|
|
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
|
|
|
Post by StefanPendl on Aug 13, 2013 23:41:51 GMT -5
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.
|
|
|
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.
|
|
|
Post by krzysztof on Sept 5, 2013 5:34:27 GMT -5
Run BASIC 6.3 - 8 sec Just BASIC 49 - 53.5 sec Liberty BASIC about 49 sec Why is there such a difference in the speed of the RB and JB/LB, since both are working on the same code?
|
|
|
Post by StefanPendl on Sept 5, 2013 17:11:53 GMT -5
JB/LB are developed using an older development tool. RB on the other hand uses the latest release of that development tool.
LB5 should be at least as fast as RB.
|
|
|
Post by krzysztof on Sept 6, 2013 3:04:33 GMT -5
Sounds interesting!
|
|
|
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.
|
|
|
Post by StefanPendl on Sept 7, 2013 9:13:30 GMT -5
This will change with the release of JB2, which will be based on the same code base as RB.
|
|
|
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.
|
|