Evan Martin (evan) wrote in evan_tech,
Evan Martin

time profiling

In C, constructs like "while" and "for" are built into the language. In this fascinating history of Haskell they mention that in higher-level languages (Ruby is an example, too), these control-flow constructs are built as functions in the standard libraries, which makes function-based profiling not as useful:
... knowing that map consumes 20% of execution time is little help to the programmer—we need to know instead which occurrence of map stands for a large fraction of the time. Likewise, when one logical task is implemented by a combination of higher-order functions, then the time devoted to the task is divided among these functions in a way which disguises the time spent on the task itself. [from section 10.1]
I'd encountered this in Ruby profiling too, but I hadn't really identified it as a problem that needed solving. See, for example, this flat profile (from a Ruby profiler project), where Integer#upto (the rough equivalent of a for loop) is at the top. The more general problem for profilers is that control flow isn't neatly nested in these languages, and this problem is worse with laziness.

In the Haskell world, solutions to problems always involve publishing a paper. Here's the overview from the GHC manual: you can annotate sections of your code with names and the profiler assigns time to those sections.

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.