I've been trying to optimize a bit of code the past couple of days, but think I might be misunderstanding how compilation on certain target functions works. As a most barebones example, I've attached a screenshot below of the speeds for array creation using ConstantArray, Table, and the compiled versions of each.
We see that ConstantArray is nearly 10x faster than Table in this most simple case (perhaps not surprisingly given that simplicity). When we try to compile, ConstantArray cannot be compiled, and so the time taken just increases because of overhead, I assume. However, the compiled Table call also increases in time. This is unexpected to me, so I figure I must be doing something wrong in this comparison. Any thoughts on how to yield a speed increase from compiling Table, if it is possible in such a situation? I should also note that using Array is categorically slower than both other options, for both uncompiled, and compiled.