Add standard debug function with profiling.

See Issue #331