I wrote a very primitive script to produce a flamegraph out of a number of asciidoc files. See this blog post for some idea of the result.
WARNING: It's heavily taylored to my own setup, so not sure it'll work directly with yours, or you might have some customization to do. (If there's enough interest I could do a more general script / Dockerfile.)
How to use?
get the flamegraph tool:
git clone --depth 1 email@example.com:brendangregg/FlameGraph.git
get the python code included in this file
then run the following command:
python get_sections.py flamegraph | ./FlameGraph/flamegraph.pl > flamegraph.svg
then open the
flamegraph.svg in your browser.
note that you can also check what your sections are with this command:
What is the expected setup
This is the expected file structure:
your_folder/ ├── manuscript/ # your book │ ├── 1_some_chapter.adoc # chapters must be named <num>_<name>.adoc │ └── 2_some_other_chapter.adoc ├── Flamegraph/ # the clone of the FlameGraph repository └── get_sections.py # the file contained in this gist
If you have a different file structure, you might want to replace this snippet of code with a manual list of your files:
filenames = glob.glob("./manuscript/*_*.adoc") filenames = sorted(filenames, key=lambda line: int( os.path.basename(line).split("_", 1)))
as well as get the chapter number in a different way:
# get chapter number chapt_num = int(name.split("_", 1))
.adoc files that start with the name of the chapter as depth-1 heading:
= Chapter Title == first section === first subsection
if you do not have such a convention, you might want to change this part:
match depth: # main title: initialization case 1:
case x if len(prefix) == 0: