Category : Files from Magazines
Archive   : DDJ0788.ZIP
Filename : BASIC.4

 
Output of file : BASIC.4 contained in archive : DDJ0788.ZIP
[FILENAME: BENCHOLD.TB]

DEFINT A-Z
DIM t!(28)
OPEN "bas6.tim" FOR OUTPUT AS #1
'time for a raw 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 a integer assignment loop, executed 1,000,000 times.
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 integer adds
y = 5: z = -5
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = x + y
x = x + z
NEXT j
NEXT i
t!(2) = (TIMER - t! - t!(0)) / 2 - t!(1)

'time for 1,000,000 integer subtracts
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = x - y
x = x - z
NEXT j
NEXT i
t!(3) = (TIMER - t! - t!(0)) / 2 - t!(1)

'time for 1,000,000 integer multiplies
k = 7
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 1000
x = k * j
NEXT j
NEXT i
t!(4) = TIMER - t! - t!(1)

'time for 1,000,000 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 string assignments
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x$ = "abcdefghijklmnopqrstuvwxyz"
x$ = "zyxwvutsrqponmlkjihgfedcba"
NEXT j
NEXT i
t!(6) = (TIMER - t! - t!(0) / 10) / 2

'time for 100,000 string MID$ operations
x$ = "abcdefghijklmnopqrstuvwxyz"
k = 17
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
MID$(x$, k, 1) = "d"
NEXT j
NEXT i
t!(7) = TIMER - t! - t!(0) / 10

'time for 10,000 string concatenations
x$ = ""
t! = TIMER
FOR i = 1 TO 10000
x$ = x$ + "a"
NEXT i
t!(8) = TIMER - t! - t!(6) - t!(0) / 100

'time for a single-precision assignment loop, executed 1,000,000 times.
y! = 5!: z! = -5!
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x! = y!
x! = z!
NEXT j
NEXT i
t!(9) = (TIMER - t! - t!(0)/10) / 2

'time for 1,000,000 single-precision adds
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x! = x! + y!
x! = x! + z!
NEXT j
NEXT i
t!(10) = (TIMER - t! - t!(0)/10) / 2 - t!(9)

'time for 1,000,000 single-precision subtracts
x! = 0!
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x! = x! - y!
x! = x! - z!
NEXT j
NEXT i
t!(11) = (TIMER - t! - t!(0)/10) / 2 - t!(9)

'time for 100,000 single-precision multiplies
x! = 1!
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x! = x! * 1.00001
NEXT j
NEXT i
t!(12) = (TIMER - t! - t!(0) / 10) / 2 - t!(9)

'time for 100,000 single-precision divides
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x! = x! / 1.00001
NEXT j
NEXT i
t!(13) = (TIMER - t! - t!(0) / 10) / 2 - t!(9)

'error in single-precision multiply/divide
t!(14) = x! - 1!

'time for 10,000 single-precision exponentiations
x! = 100!
t! = TIMER
FOR i = 1 TO 1000
x! = x! ^ .999999
NEXT i
t!(15) = (TIMER - t! - t!(0) / 1000) / 2 - t!(9) / 100

'time for a double-precision assignment loop, executed 1,000,000 times.
y# = 5.5#: z# = -5.5#
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x# = y#
x# = z#
NEXT j
NEXT i
t!(16) = (TIMER - t! - t!(0)/10) / 2

'time for 1,000,000 double-precision adds
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x# = x# + y#
NEXT j
NEXT i
t!(17) = TIMER - t! - t!(16) - t!(0)/10

'time for 1,000,000 double-precision subtracts
x# = 0#
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
x# = x# - y#
NEXT j
NEXT i
t!(18) = TIMER - t! - t!(16) - t!(0)/10

'time for 100,000 double-precision multiplies
x# = 1#
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 10
x# = x# * 1.00001#
NEXT j
NEXT i
t!(19) = (TIMER - t! - t!(0) / 100) - t!(16) / 10

'time for 100,000 double-precision divides
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 10
x# = x# / 1.00001#
NEXT j
NEXT i
t!(20) = (TIMER - t! - t!(0) / 100) - t!(16) / 10

'error in double-precision multiply/divide
t!(21) = x# - 1#

'time for 10,000 double-precision exponentiations
x# = 100#
t! = TIMER
FOR i = 1 TO 1000
x# = x# ^ .999999#
NEXT i
t!(22) = (TIMER - t! - t!(0) / 1000) - t!(16) / 100


'following are logical comparisons and operators

'time for 1,000,000 integer comparisons
x = 0
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
IF i < x THEN x = 1
NEXT j
NEXT i
t!(23) = TIMER - t! - t!(0)/10

'time for 1,000,000 single-precision comparisons
x! = 5!: y! = 3.333
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
IF x! < y! THEN x = 1
NEXT j
NEXT i
t!(24) = TIMER - t! - t!(0)/10

'time for 1,000,000 double-precision comparisons
x# = 5#: y# = 3.333#
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
IF x# < y# THEN x = 1
NEXT j
NEXT i
t!(25) = TIMER - t! - t!(0)/10

'is there short-circuit expression evaluation?
'integer loop, 1,000,000 times
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
IF i < 0 AND j < 10 THEN x = 1
NEXT j
NEXT i
t!(26) = TIMER - t! - t!(0)/10
t! = TIMER
FOR i = 1 TO 1000
FOR j = 1 TO 100
IF j < 10 AND i < 0 THEN x = 1
NEXT j
NEXT i
t!(27) = TIMER - t! - t!(0)/10
'Note: if the two times are appreciably different, some optimization has been
'done. The first time should be shorter than the second.

'screen output: print 1,000 70-byte strings
x$ = STRING$(70, 66)
t! = TIMER
FOR i = 1 TO 1000
PRINT x$
NEXT i
t!(28) = TIMER - t! - t!(0) / 1000


'print results of benchmark
PRINT #1, "Empty integer loop, 1,000,000 iterations:"; TAB(46); t!(0)
PRINT #1, "1,000,000 integer assignments:"; TAB(46); t!(1)
PRINT #1, "1,000,000 integer additions:"; TAB(46); t!(2)
PRINT #1, "1,000,000 integer subtractions:"; TAB(46); t!(3)
PRINT #1, "1,000,000 integer multiplications:"; TAB(46); t!(4)
PRINT #1, "1,000,000 integer divisions:"; TAB(46); t!(5)
PRINT #1, "100,000 string assignments:"; TAB(46); t!(6)
PRINT #1, "100,000 string MID$ operations:"; TAB(46); t!(7)
PRINT #1, "10,000 string concatenations:"; TAB(46); t!(8)
PRINT #1, "1,000,000 single-precision assignments:"; TAB(46); t!(9)*10
PRINT #1, "1,000,000 single-precision additions:"; TAB(46); t!(10)*10
PRINT #1, "1,000,000 single-precision subtractions:"; TAB(46); t!(11)*10
PRINT #1, "100,000 single-precision multiplications:"; TAB(46); t!(12)
PRINT #1, "100,000 single-precision divisions:"; TAB(46); t!(13)
PRINT #1, "Error in 100,000 single-precision mult/div:"; TAB(46); t!(14)
PRINT #1, "10,000 single-precision exponentiations:"; TAB(46); t!(15)*10
PRINT #1, "1,000,000 double-precision assignments:"; TAB(46); t!(16)*10
PRINT #1, "1,000,000 double-precision additions:"; TAB(46); t!(17)*10
PRINT #1, "1,000,000 double-precision subtractions:"; TAB(46); t!(18)*10
PRINT #1, "100,000 double-precision multiplications:"; TAB(46); t!(19)*10
PRINT #1, "100,000 double-precision divisions:"; TAB(46); t!(20)*10
PRINT #1, "Error in 100,000 double-precision mult/div:"; TAB(46); t!(21)*10
PRINT #1, "10,000 double-precision exponentiations:"; TAB(46); t!(22)*10
PRINT #1, "1,000,000 integer comparisons:"; TAB(46); t!(23)*10
PRINT #1, "1,000,000 single-precision comparisons:"; TAB(46); t!(24)*10
PRINT #1, "1,000,000 double-precision comparisons:"; TAB(46); t!(25)*10
PRINT #1, "1,000,000 conditional integer assignments:"; TAB(46); t!(26)*10
PRINT #1, "1,000,000 conditional assignments (reversed):"; TAB(46); t!(27)*10
PRINT #1, "Print 1,000 70-byte strings to the screen:"; TAB(46); t!(28)
END



  3 Responses to “Category : Files from Magazines
Archive   : DDJ0788.ZIP
Filename : BASIC.4

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/