Setting SetSystemOptions[ "CompileOptions" -> "CompileReportExternal"->True]
will emit a message when parts of your function do not get compiled. After compilation, Needs["CompiledFunctionTools`"]
followed by CompilePrint[cF]
(with cF
the function you have compiled will display some bytecode; looking for CopyTensor
or MainEvaluate
in that helps locate inefficiencies (MainEvaluate
calls the main mma kernel, so it effectively means not compiling).
Other useful options may be found by evaluating SystemOptions["CompileOptions"]
EDIT: As suggested by Oleksandr in a comment, On[Compile::noinfo]
is also useful.