Why is this numerical scheme so much faster when using `collect()` than a for loop?

If your measure claims that something that should take quite some time happens in basically no time, assume that your benchmarking is broken. In this case foo(a) mutates a and removes all elements. The call to bar(a) operates on an empty vector, which indeed is very fast.

3 Likes