GPT question on optimisation, is it being sarcastic?

1000 simple bounds checks in memory is extremely fast — even in Xojo.

well you can check for yourself what the bounds check cost is

build a console app that has them enabled
do a billion operations that would require bounds checks (something on an array that DOESNT get optimized to a static value by the compiler)

compile it and have it spit out numbers for start & end times

then do the same but put in the pragma to disable bounds checking

compile it and run it again

compare

but yeah it is small even in Xojo
but depending on the # you’re doing a large # can / could have a measurable hit

// #Pragma BoundsChecking False
Dim intarray(10) As IntegerDim starttime , endtime As Double

starttime = Microseconds

For i As Integer = 0 To 1000000000

Dim j As Integer

j = intarray( foo() ) // need to make sure this dosnt get optimized out

Next

endtime = Microseconds

Print Format(endtime - starttime, “######.00000”) + " microseconds"

the Foo method just returns 1

not sure if that call would be optimized down to a static inline of the value 1
and how the array access might be optimized if it did

without the pragma : 46260197.07397 microseconds

enabled to skip bound check :stuck_out_tongue: 45848988.40405 microseconds

411208.66992 microseconds over 1 billion iterations