What's the best way for profiling the code of an EOS.IO smart contract? I'd like to know what percentage of the CPU time is spent on executing each function\line (including multi index table function calls) within actions.
Its not possible to check each function/line, but you can test each action. Maybe you could test each function by creating a specific action that calls exactly one line of code/one function each.
When you call an action using cleos, it will tell you on screen how many seconds of CPU time you were charged. For example:
cleos transfer accounta accountb "1 EOS" "memo" 2>&1 | grep "executed transaction" | cut -d' ' -f 8
This will tell you how many microseconds the transaction took