_TITLE "Expandable Speed Comparison Tool"
CONST LIMIT
= 1 'time allowed for tests (in seconds)
'An expandable list of things to test
DATA "+","-","^","*","/","\","INT"
Int AS _FLOAT 'to store times with integers being tested Float
AS _FLOAT 'to store times with floats being tested Index
AS LONG 'to store the index of the operation, in case we want to sort the results at a later date as we generate more data
DIM Times
(1000) AS Results
'to hold the number of times we can run in a LIMIT
DO UNTIL t$
= "DONE" 'Read in the test results IF t$
<> "DONE" THEN count##
= count##
+ 1: TestString
(count##
) = t$
PRINT "Running tests. Wait"; count##
* 2;
" seconds..."
counter## = 0
counter## = counter## + 1
junk
= RND * 1000000 + 1 'just some random junk to test junk1
= RND * 1000000 + 1 'add one so we never get division by 0 glitches SELECT EVERYCASE TestString
(counter##
) 'We use everystring here so we don't skew results with fast exit CASE comparisons CASE "+": junk
= junk
+ junk1
CASE "-": junk
= junk
- junk1
CASE "^": junk
= junk
^ junk1
CASE "*": junk
= junk
* junk1
CASE "/": junk
= junk
/ junk1
CASE "\": junk
= junk \ junk1
CASE "^.5": junk
= junk
^ 0.5 CASE "x + x": junk
= junk
+ junk
CASE "x * 2": junk
= junk
* 2 Times
(counter##
).
Int = Times
(counter##
).
Int + 1
'Simply copy/paste a duplicate of the SELECT CASE from above to here for _FLOAT comparison speeds
junk
= RND * 1000000 + 1 'just some random junk to test junk1
= RND * 1000000 + 1 'add one so we never get division by 0 glitches SELECT EVERYCASE TestString
(counter##
) 'We use everystring here so we don't skew results with fast exit CASE comparisons CASE "+": junk
= junk
+ junk1
CASE "-": junk
= junk
- junk1
CASE "^": junk
= junk
^ junk1
CASE "*": junk
= junk
* junk1
CASE "/": junk
= junk
/ junk1
CASE "\": junk
= junk \ junk1
CASE "^.5": junk
= junk
^ 0.5 CASE "x + x": junk
= junk
+ junk
CASE "x * 2": junk
= junk
* 2 Times(counter##).Float = Times(counter##).Float + 1
PRINT "Testing speed for: "; TestString
(i
), PRINT "FLOATS:"; Times
(i
).Float