pre-allocating array is slow

Welcome! Two things:

  • Please mark your code as such with ``` backtick blocks so it formats nicely here
  • Take a look at the Performance Tips manual page and in particular the very first section: You want to ensure the code you benchmark is inside a function. Do that and it should be the fastest of all three options.