This is an hard one: 1 million FOR/NEXT loop done inside a function.
[code=thinbasic]
DIM MaxCount AS LONG value 1000000
DIM T1 AS DOUBLE
DIM T2 AS DOUBLE
DIM Message AS STRING
Message = "This program will count " & MaxCount & " times.\n"
Message += "Please press Yes to go on, NO to Stop\n"
DIM lResult AS LONG = MSGBOX(0, Message, %MB_YESNO, "Continue?")
IF lResult <> %IDYES THEN
STOP
END IF
'---Speed up operations a bit
doevents(off)
T1 = TIMER
Counter
T2 = TIMER
MSGBOX 0, "Seconds:" & $tab & $tab & FORMAT$(T2 - T1, "#0.000000")
function Counter() as long
Dim i, j as long
For i = 1 To MaxCount
INCR j
Next
end function
[/code]
Try to change Counter function with something different like:
[code=thinbasic] function Counter() as long
Dim i, j as long
For i = 1 To MaxCount
j = sin(i)
j = cos(i)
Next
end function
[/code]
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
375 ms for the first one.
1.453 seconds for the second one.
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Bookmarks