down from 8 to 5 seconds by creating the DimArray at the end, still not great
down to 0.5s by avoiding the use of DimArrays in the middle and special-casing the nprof==0 case