Why is the access to DWORD-VarPtr three times slower (as LONG-VarPtr)?
Is there a faster way for access on big array?
Is there a faster way for access on big array?
Code:
#COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG LOCAL i AS LONG LOCAL a1 AS LONG LOCAL a2 AS DWORD LOCAL t1, t2, t3 AS SINGLE DIM arr(500000000) AS BYTE [B]' a1 --> long --> is speedy[/B] a1 = VARPTR(arr(LBOUND(arr))) t1 = TIMER FOR i = LBOUND(arr) TO UBOUND(arr) POKE a1, i+1 INCR a1 NEXT i t1 = TIMER - t1 [B]' a2 --> dword --> is slower[/B] a2 = VARPTR(arr(LBOUND(arr))) t2 = TIMER FOR i = LBOUND(arr) TO UBOUND(arr) POKE a2, i+1 INCR a2 NEXT i t2 = TIMER - t2 [B]' with array access --> is medium[/B] t3 = TIMER FOR i = LBOUND(arr) TO UBOUND(arr) arr(i) = i+1 NEXT i t3 = TIMER - t3 MSGBOX "1. Method:" + STR$(t1) + $CR+$CR + "2. Method:" + STR$(t2) + $CR+$CR + "3.Method:" + STR$(t3) END FUNCTION
Comment