home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1988
/
07
/
bench
/
benchnew.bas
next >
Wrap
BASIC Source File
|
1988-04-29
|
3KB
|
130 lines
[FILENAME: BENCHNEW.BAS]
DEFLNG A-Z
DIM t!(28)
OPEN "bas6new.tim" FOR OUTPUT AS #1
DIM x1 AS STRING * 1
DIM x26 AS STRING * 26
DIM x70 AS STRING * 70
DIM x10000 AS STRING * 10000
'time for a raw long integer loop, executed 1,000,000 times.
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
NEXT j
NEXT i
t!(0) = TIMER - t!
'time for 1,000,000 long integer assignments.
y = 5&: z = -5&
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = y
x = z
NEXT j
NEXT i
t!(1) = (TIMER - t! - t!(0)) / 2
'time for 1,000,000 long integer adds
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = x + y
NEXT j
NEXT i
t!(2) = TIMER - t! - t!(1)
'time for 1,000,000 long integer subtracts
x = 0
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = x - y
NEXT j
NEXT i
t!(3) = TIMER - t! - t!(1)
'time for 1,000,000 long integer multiplies
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = i * j
NEXT j
NEXT i
t!(4) = TIMER - t! - t!(1)
'time for 1,000,000 long integer divides
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = i \ j
NEXT j
NEXT i
t!(5) = TIMER - t! - t!(1)
'time for 100,000 fixed string assignments
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x26 = "abcdefghijklmnopqrstuvwxyz"
x26 = "zyxwvutrsqponmlkjihgfedcba"
NEXT j
NEXT i
t!(6) = (TIMER - t! - t!(0) / 10) / 2
'time for 100,000 fixed string MID$ operations
k = 17
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
MID$(x26, k, 1) = "d"
NEXT j
NEXT i
t!(7) = TIMER - t! - t!(0) / 10
'time for 10,000 fixed string "concatenations"
x$ = ""
t! = TIMER
FOR i = 1 TO 10000
MID$(x10000, i, 1) = "a"
NEXT i
t!(8) = TIMER - t! - t!(0) / 100
'following are logical comparisons and operators
'time for 1,000,000 long integer comparisons
x = 5&: y = -5&
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
IF i < y THEN x = 1
NEXT j
NEXT i
t!(23) = TIMER - t! - t!(0)
'screen output: print 1,000 70-byte fixed strings
x70 = STRING$(70, 66)
t! = TIMER
FOR i = 1 TO 1000
PRINT x70
NEXT i
t!(28) = TIMER - t! - t!(0) / 1000
'print results of benchmark
PRINT #1, "Raw long integer loop, 1,000,000 iterations:"; TAB(45); t!(0)
PRINT #1, "1,000,000 long integer assignments:"; TAB(45); t!(1)
PRINT #1, "1,000,000 long integer additions:"; TAB(45); t!(2)
PRINT #1, "1,000,000 long integer subtractions:"; TAB(45); t!(3)
PRINT #1, "1,000,000 long integer multiplications:"; TAB(45); t!(4)
PRINT #1, "1,000,000 long integer divisions:"; TAB(45); t!(5)
PRINT #1, "100,000 fixed string assignments:"; TAB(45); t!(6)
PRINT #1, "100,000 fixed string MID$ operations:"; TAB(45); t!(7)
PRINT #1, "10,000 fixed string concatenations:"; TAB(45); t!(8)
PRINT #1, "1,000,000 long integer comparisons:"; TAB(45); t!(23)
PRINT #1, "Print 1,000 70-byte strings to the screen:"; TAB(45); t!(28)
END