I have a relatively small function, which my profiler has indicated is taking a majority of the time and was hoping to optimize it some. Looking over some of the recent posts, I have been able to make some progress but would like to see if this can be sped up any more. What the function does is extract the value of two bits from a passed in byte. The code as it is now is:
Changing from a SELECT CASE to the On ... GoTo made a big improvement. From looking at this code is there anything else I can do to make this faster?
Also, in another function (which now takes most of the time), the two lines consuming most clock cycles are:
Is there any way to speed these up at all?
I am looking forward dot your responses. Many thanks in advance.
Best regards,
Andrew Peskin
[email protected]
------------------
[This message has been edited by Andrew Peskin (edited March 21, 2001).]
Code:
Private Function Extract_TWO_Bits(TheBYTE As Byte, Position As Integer) As Integer On Position GoTo Zero, Two, Four, Six Zero: '// Isolates BITS 0 and 1 Extract_TWO_Bits = (TheBYTE And 3) '// 3 = &H3 Exit Function Two: '// Isolates BITS 2 and 3 Extract_TWO_Bits = (TheBYTE And 12) \ 4 '// 12 = &HC Exit Function Four: '// Isolates BITS 4 and 5 Extract_TWO_Bits = (TheBYTE And 48) \ 16 '// 48 = &H30 Exit Function Six: '// Isolates BITS 6 and 7 Extract_TWO_Bits = TheBYTE \ 64 Exit Function End Function
Also, in another function (which now takes most of the time), the two lines consuming most clock cycles are:
Code:
INTPortion = Int(RAWPrice / 100#) DECPortion = ((RAWPrice / 100#) - INTPortion) * 100#
I am looking forward dot your responses. Many thanks in advance.
Best regards,
Andrew Peskin
[email protected]
------------------
[This message has been edited by Andrew Peskin (edited March 21, 2001).]
Comment