Re: Long Vs Integer
I don't understand the killjoy comment ...
[ss=
---A--- --------B---------
2 Seconds
3 Byte 2.13
4 Integer 2.58
5 Long 2.18
6 Single 2.30
7 Double 2.30 ]*[/ss]
Re: Long Vs Integer
I don't understand the killjoy comment ...
[ss=
---A--- --------B---------
2 Seconds
3 Byte 2.13
4 Integer 2.58
5 Long 2.18
6 Single 2.30
7 Double 2.30 ]*[/ss]
Re: Long Vs Integer
2003
[ss= Seconds
Byte 1.4063
Integer 1.3281
Long 1.3125
Single 1.5313
Double 1.5313]*[/ss]
2007
[ss= Seconds
Byte 1.4063
Integer 1.4219
Long 1.2813
Single 1.5352
Double 1.5000
]*[/ss]
Machine: Lenovo T60 - T2500 @2GB Core Duo CPU - 2GB RAM
Re: Long Vs Integer
What suprised me was how much difference the "compile" makes.
Overall the Long is a bit faster than the integer despite being twice the size so I think the standard should be to dim as Long.
On a Pentium 4 - 2.8 I found the results spread in the 2 to 4 second range with Long just winning. I'll have dust off my Core 2 to compete with Will's times !
Re: Long Vs Integer
Quote from carlmackI'll have dust off my Core 2 to compete with Will's times !
- Impressive for a laptop innit ?
The T60, it does fly when put to work. If it could only use some of that massive processing power to work out the difference between being docked & undocked and not periodically freeze up it's keyboard on booting, it would be a superb machine!! Sometimes I have to reboot 2 or 3 times when undocked to get every peripheral working. Frustrating when you're constantly on the move.....
Re: Long Vs Integer
Quote
Impressive for a laptop innit ?
Yer for a laptop very impressive.
Core 2 6400
Byte 1.2656
Integer 1.2188
Long 1.1719
Single 1.3594
Double 1.3594
I can't see any variation in times with Core 2 ??
Anybody got one of those Quad core things yet ?
Re: Long Vs Integer
QuoteWhat suprised me was how much difference the "compile" makes.
Yes, it's a MUST when speed testing, sadly though not often done. The 1st time a Procedure in any Module is run, the whole Module is compiled. This is why ALL related Procedures should reside in the same Module.
Also, I may be wrong, but I believe Excel uses built-in processing over what it free at the time. This means no matter how "fast" the laptop/PC is, it wont make much difference.
Re: Long Vs Integer
Going to engage in a bit of Necromancy here (reviving long dead posts), since I stumbled across this...
I would hope that VBA does not convert everything to Long when allocating storage. So in the case of large data structures (arrays etc) then it would still make sense to use Byte or Integer. Yes there will be a performance penalty for performing calculations on the elements but it does not make sense to double or quadruple the storage requirements if the data structure is large but the values being stored do not require it.
If VBA does convert everything to Long even for storage allocation then:
1) The type definitions are pointless
2) I will have to hunt Bill Gates down and kill him :razz:
Re: Long Vs Integer
I believe he works in "1 microsoft way, Redmond"... ask the locals if you get lost, I'm sure they'll point you in the right direction
Re: Long Vs Integer
Are you telling me VBA really does convert everything to Long even for storage???
Re: Long Vs Integer
Nah, it would appear not... never really thought about it, but in the interest of science 'n stuff, I checked it using the LENB function... take a look if you want:
Type my_structure
x As Integer
y As Integer
z As Integer
End Type
Type my_structure2
a As Long
b As Long
c As Long
End Type
Public Sub test()
Dim ibyte As Byte
Dim iinteger As Integer
Dim iLong As Long
Dim v As Variant
Dim my_struct As my_structure
Dim my_struct2 As my_structure2
Dim arr(1 To 2) As Integer
v = 10
Debug.Print "ibyte storage =" & LenB(ibyte)
Debug.Print "iinteger storage =" & LenB(iinteger)
Debug.Print "ilong storage =" & LenB(iLong)
Debug.Print "v storage of a byte size value =" & LenB(v)
Debug.Print "struct storage of integers =" & LenB(my_struct)
Debug.Print "struct2 storage of longs =" & LenB(my_struct2)
Debug.Print "arr storage = " & LenB(arr(1))
End Sub
Display More
Still think you should go through with you plan though
Ger
Re: Long Vs Integer
Useful science!
Well I will give it some thought, but unless I can make it retroactive by about 35 years its not really going to improve things much
Don’t have an account yet? Register yourself now and be a part of our community!