Make sure you have in Compile tab, behind Advanced optimizations button:- Remove array boundary check
- Remove integer overflow check
- Remove floating point check
Having these ticked will dramatically reduce performance issues, but may also introduce new bugs if there is code that relies on error triggering.
I can't recall how good performance Abs has and not in the mood for a benchmark. It should be quite straightforward function, but in case it isn't:
Code:
Dim Temp As Long
Dim Total As Long
For i = 0 to MemLen
Temp = tempMemI(i)
If Temp < 0 Then
Total = Total - Temp
Else
Total = Total + Temp
End If
Next
AvgValue(BufferNo) = Total / TempBuff
May perform faster despite longer code.
However, datatype coercing always introduces some speed decrease (in this case Integer -> Long, but you have to do it).