Xhprof is a project mainly written in PHP and JAVASCRIPT, it's free.
Code from https://github.com/facebook/xhprof