Performance tuning

What are the best practices for optimizing custom indicator code? I’m particularly looking at what tools I can use to profile the performance of indicators in action on the charts whether within chrome dev tools or the code editor.