Say I have a large chunk of data that I want to use in a
function repeatedly. If I pass it normally, the computer by
default creates a new copy of that data for the function to
work with. But if you use Var, it creates a pointer to
the data, right?
Well that's what I thought anyway. If you run this code
with and without Var written in the function declaration,
you'll notice that using Var is actually slower. How
can transfering a huge chunk of data be quicker than
transfering a measly pointer? What's going on here?
function repeatedly. If I pass it normally, the computer by
default creates a new copy of that data for the function to
work with. But if you use Var, it creates a pointer to
the data, right?
Well that's what I thought anyway. If you run this code
with and without Var written in the function declaration,
you'll notice that using Var is actually slower. How
can transfering a huge chunk of data be quicker than
transfering a measly pointer? What's going on here?
Strict Local times = 40 Local avg:Float Local arr[100,1000,1000] For Local tt = 0 To times Local time = MilliSecs() For Local a = 0 To 500000 frat(arr) Next Print MilliSecs()- time avg:+MilliSecs()- time Next Print Print "Average time: "+avg/(times+1) Function frat(arr[,,] Var) End Function