hab mal nen speedtest gemacht.
Code: Alles auswählen
Macro LoNib( Value )
( ( Value ) & $000F )
EndMacro
Macro LoMiNib( Value )
( ( ( Value ) & $00F0 ) >> 4 )
EndMacro
Macro HiMiNib( Value )
( ( ( Value ) & $0F00 ) >> 8 )
EndMacro
Macro HiNib( Value )
( ( ( Value ) & $F000 ) >> 12 )
EndMacro
Macro GetBits(Value, Size, Start)
( ( (Value) >> (Start) ) & Int(Pow(2,Size)-1) )
EndMacro
Macro GetBits2(Value, Size, Start)
( ( (Value) >> Start ) & ((1 << Size)-1) )
EndMacro
timer = ElapsedMilliseconds()
timer1 = ElapsedMilliseconds()
For t=0 To 99
For n=0 To 65535
a = GetBits(n, 4, 0)
b = GetBits(n, 4, 4)
c = GetBits(n, 4, 8)
d = GetBits(n, 4,12)
Next
Next
timer1 = ElapsedMilliseconds() - timer1
timer2 = ElapsedMilliseconds()
For t=0 To 999
For n=0 To 65535
a = GetBits2(n, 4, 0)
b = GetBits2(n, 4, 4)
c = GetBits2(n, 4, 8)
d = GetBits2(n, 4,12)
Next
Next
timer2 = ElapsedMilliseconds() - timer2
timer3 = ElapsedMilliseconds()
For t=0 To 999
For n=0 To 65535
a = LoNib(n)
b = LoMiNib(n)
c = HiMiNib(n)
d = HiNib(n)
Next
Next
timer3 = ElapsedMilliseconds() - timer3
timer = ElapsedMilliseconds() - timer
text$ = "Allgemeines Macro mit Pow()" + #CRLF$
text$ + "100 Durchläufe " + Str(timer1) + "ms" + #CRLF$ + #CRLF$
text$ + "Allgemeines Macro mit Shift" + #CRLF$
text$ + "1000 Durchläufe " + Str(timer2) + "ms" + #CRLF$ + #CRLF$
text$ + "Spezielle Macros" + #CRLF$
text$ + "1000 Durchläufe " + Str(timer3) + "ms" + #CRLF$ + #CRLF$
text$ + "Gesamtlaufzeit" + #CRLF$
text$ + Str(timer) + "ms"
MessageRequester("GetBits Macros Speedtest", text$ )
damit aussagekräftigere werte rauskommen.
da frag ich mich, wie ich auf die beknackte idee kommen konnte,
die elendig komplexe funktion Pow() zu verwenden.
merke:
zum potenzieren von zweierpotenzen stets Bitshift verwenden!