Blizzard has made a large programmable environment and hundreds of modders are making useful mods in it. Yet there is very little support inside the game for debugging, profiling, tracking and so forth.
There are some useful add-ons which can help you in making your own add-ons or with checking what is going on in your client. I have found them extremely useful when checking memory requirements of my add-on collection in addition to trying to figure out which add-on was using most of my processing power.
So, here are few useful tips for add-ons which give you some useful profiling and debugging abilities.
DevTools from Iriel allows executing Lua expressions and lets you work with Chat Events. Also shows a Frame Stack.
OnEventWatch from Gello will let you know which frames OnEvent is taking too long to execute. Based on this one can optimise code.
LuaProfiler allows you to trace functions calls and reports how much time was spent in that function (on average and peak).
Warmup has helped me a lot when there were issues with long times of zoning. It can also show how much memory is taken by which add-on - with some limitation for embedded libraries (add-ons with embedded libraries show a larger footprint than they really use, after garbage collection).
KLHPerformanceMonitor tracks the memory allocation and CPU usage of all the mods running. You can report on the memory usage and CPU time of the top 10 mods.
Built-in Profiling Support
The following will show the current CPU profiling setting, in case you think you accidentally left it on: