Translation: Flame of the Day
This small piece of code helps troubleshoot slow clojure load times.
It alters clojure.core/load
to print load times to an output file of
stacks that that FlameGraph can
turn into a pretty fire.
- Clojure
- FlameGraph must be installed separately to turn the
stacks into a graph. Just clone that repository so you can run
flamegraph.pl
. It requiresperl
. - The example in the README is with Leiningen, but there's nothing about the codebase that is Leiningen specific.
flame-du-jour.core/-main
takes an output-file and a code snippet to run.
If using leiningen, adding flame-du-jour to your user profile dependencies makes it conveninent to use.
{:user {:dependencies [[ryfow/flame-du-jour "0.1.0"]]}}
Then, in a project I'm working in (for example refactor-nrepl), run the following from a command line:
% lein run -m flame-du-jour.core flames.txt "(require 'refactor-nrepl.middleware :reload-all)"
That should create a stacks file in current working directory named flames.txt
.
flamegraph.pl will turn the stacks file into a flames svg.
% ~/oss/FlameGraph/flamegraph.pl flames.txt > flames.svg
Most browsers support svg, so you can view it with open -a /Applications/Google\ Chrome.app flames.svg
Click on the example below to try out the full interactive version.
I've always wanted to create a Clojure library named soup-du-jour. That name doesn't really fit here and I don't find myself writing a lot of libraries, so you get flame-du-jour.
I also considered flaming-load. It was a hard decision, but I went with flame-du-jour.
Copyright © 2017 Ryan Fowler
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.