For the inspection part, have you looked at e.g. Erlang -- beam_lib?
As for efficiency, there’s an official guide at Erlang -- Efficiency Guide. There’s a chapter there on profiling, too.
Bonus: here’s a quote from Joe Armstrong on efficiency
Make it work, then make it beautiful, then if you really, really have to, make it fast. 90% of the time, if you make it beautiful, it will already be fast. So really, just make it beautiful!