add optional profiling middleware on debug
Merge pull request #792 from xi/feature-profiling

add optional profiling middleware on debug