View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Brad Patterson Brad Patterson is offline
external usenet poster
 
Posts: 16
Default My macros are slowing down.

Very sorry, the link was incorrect ... A very unlucky search for my
³speedtype.xls² file found something totally useless (... To me anyway) ...

I can¹t find where I got it now ... The code in the macro was as follows ...

Sub Test()

Dim t As Single

Dim tByte0 As Byte, tByte1 As Byte, tByte2 As Byte, tByte3 As Byte
Dim tInt0 As Integer, tInt1 As Integer, tInt2 As Integer, tInt3 As Integer
Dim tLong0 As Long, tLong1 As Long, tLong2 As Long, tLong3 As Long
Dim tSingle0 As Single, tSingle1 As Single, tSingle2 As Single, tSingle3 As
Single
Dim tDouble0 As Double, tDouble1 As Double, tDouble2 As Double, tDouble3 As
Double
Dim tVariant0 As Variant, tVariant1 As Variant, tVariant2 As Variant,
tVariant3 As Variant

'clear
Range("b3:b8").ClearContents

'test byte
t = Timer
For tByte0 = 1 To 254
For tByte1 = 1 To 254
For tByte2 = 1 To 254
tByte3 = (tByte2 + tByte1 / tByte0) Mod 200
Next tByte2
Next tByte1
Next tByte0
t = Timer - t
Cells(3, 2) = t

'test integer
t = Timer
For tInt0 = 1 To 254
For tInt1 = 1 To 254
For tInt2 = 1 To 254
tInt3 = (tInt2 + tInt1 / tInt0) Mod 200
Next tInt2
Next tInt1
Next tInt0
t = Timer - t
Cells(4, 2) = t

'test long
t = Timer
For tLong0 = 1 To 254
For tLong1 = 1 To 254
For tLong2 = 1 To 254
tLong3 = (tLong2 + tLong1 / tLong0) Mod 200
Next tLong2
Next tLong1
Next tLong0
t = Timer - t
Cells(5, 2) = t

'test single
t = Timer
For tSingle0 = 1 To 254
For tSingle1 = 1 To 254
For tSingle2 = 1 To 254
tSingle3 = (tSingle2 + tSingle1 / tSingle0) Mod 200
Next tSingle2
Next tSingle1
Next tSingle0
t = Timer - t
Cells(6, 2) = t

'test doublw
t = Timer
For tDouble0 = 1 To 254
For tDouble1 = 1 To 254
For tDouble2 = 1 To 254
tDouble3 = (tDouble2 + tDouble1 / tDouble0) Mod 200
Next tDouble2
Next tDouble1
Next tDouble0
t = Timer - t
Cells(7, 2) = t

'test variant
t = Timer
For tVariant0 = 1 To 254
For tVariant1 = 1 To 254
For tVariant2 = 1 To 254
tVariant3 = (tVariant2 + tVariant1 / tVariant0) Mod 200
Next tVariant2
Next tVariant1
Next tVariant0
t = Timer - t
Cells(8, 2) = t

End Sub