chshersh / dr-cabal

πŸ“Š Haskell dependencies build times profiler
https://hackage.haskell.org/package/dr-cabal
Mozilla Public License 2.0
74 stars 5 forks source link

How to share result with a friend #21

Open ulysses4ever opened 2 years ago

ulysses4ever commented 2 years ago

Hello and thanks a lot for the magnificent (as usual) tool! I absolutely love it.

Once, I wanted to share the results of profiling pandoc build (a huge build time sink) with friendly folks over on the pandoc bug tracker. But how should I do it? I can upload the json file and ask them to run dr-cabal locally. Although great for dr-cabal adoption, this is not the easiest on the folks.

Another idea is to create a gist, which is what I tried. Although bearable, it hides the portions of time spent for different phases of building per package (e.g. downloading vs. building). OTOH, I'm not sure everything else besides buliding time there is that interesting.

One probable solution is a simple web UI where I could drag-n-drop the json file and get a permalink for the result. Of course, this may require a non-trivial effort. Avoidable if the format would be supported by existing web apps to draw charts (google charts, speedscope, etc.) I didn't look into your json format, so can't say how realistic it is.

chshersh commented 2 years ago

Hi @ulysses4ever, I'm glad to hear from happy users πŸ€—

I believe the most accessible way to share the visualised results is by sharing a screenshot or even a gif (while scrolling in the terminal). For me, the highest interest represents the heaviest dependency so the screenshot of the top works for me πŸ‘πŸ»

Indeed, creating a web UI would be too much work πŸ˜… At this point, I don't have the capacity to work on this for free.

Alternatively, if there exists a popular visualisation CLI tool that can be installed in one command, dr-cabal can provide an additional flag to output the results in the format of this tool.

Although, I believe dr-cabal can be brought into the scope with Nix by a single command using nix-shell -p dr-cabal or similar. And then it can be used to visualise the original JSON.

ulysses4ever commented 2 years ago

I see, thank you! A screenshot was my first idea too, but for the particular use case I wanted more than top N packages, and Ctrl-F would be helpful there too, so I didn't go there.

I see I didn't miss anything when trying to solve it, so I'm satisfied. Feel free to close it or leave open, as you see fits...

Bodigrim commented 2 years ago

My natural instinct to save results would be to redirect stdout into file, but this does not work out of the box, because dr-cabal cannot determine terminal size: https://github.com/chshersh/dr-cabal/blob/e8d6324e0848bbdd527a65223042af94e0dc1f85/src/DrCabal/Profile.hs#L28-L38 Could we relax this check and return, say, width = 80, if terminal-size cannot determine it?

chshersh commented 2 years ago

@Bodigrim That sounds like a good default πŸ‘πŸ» I guess, this change can be done. So instead of aborting, we could a print a warning message to stderr about the default column size.

Usually, when tools print to terminal with colouring they should filter out colour codes when the output is redirected to file (so it could be read easier). But in this case, the colours are the information. So redirecting to a file with colours is the intended use case.