Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Construct flame graph from trie

I have some stats in a trie which is generated periodically. I want to generate flame graphs on the difference between two tries. How do I do that?

t = pygtrie.StringTrie(separator=os.path.sep)

for dirpath, unused_dirnames, filenames in os.walk(ROOT_DIR):
    for filename in filenames:
        filename = os.path.join(dirpath, filename)
        try:
            filestat = os.stat(filename)
        except OSError:
            continue
        if stat.S_IFMT(filestat.st_mode) == stat.S_IFREG:
            t[filename] = filestat.st_size
like image 401
Gyanendra Singh Avatar asked Nov 07 '22 16:11

Gyanendra Singh


1 Answers

Not sure about the diff. But you can draw flame graph on files (or anything else if you produce the similar output) using FlameGraph tool.

Here is a topic from the author of this tool about how to make Flame graphs for file systems. Using this tool you need just execute following command to get chart.

./files.pl /Users | ./flamegraph.pl --hash --countname=bytes > out.svg

Here is similar tool - duviz, that creates similar chart, but for CLI not as an image output. Pros - it is written in Python.

like image 103
wowkin2 Avatar answered Nov 15 '22 10:11

wowkin2