Slow and Memory intensive For Loop

Welcome to the forum!

Some remarks:

  1. please, enclose any code you share in triple back-ticks like ```
  2. if you call a function the first time it gets compiled, so call it a second time to determine the execution time
  3. avoid global variables if you need fast execution time

Finally, in this line:

allScans[:, :, ii] = readdlm(joinpath(file_location, file))

try to replace = with .= to avoid allocations.

1 Like