The k in the code snippet is not the same as the k in the expression for the array length; my bad. I've corrected the text to use "r" in the array size expression.
That said, of course the allocation and initialization of the arrays must not be within the timed part of the program. We only want to benchmark the execution, not the initialization.