Created
December 19, 2022 14:01
-
-
Save nickgnd/c6d7cabc312ea22acc0922591c735743 to your computer and use it in GitHub Desktop.
Parse eprof result and create a CSV out of it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# eprof_results is the output printed by the `eprof` profiler | |
# with the "extra" lines already stripped (e.g. "Profile done over XXX matching functions") | |
eprof_results | |
|> String.split("\n", trim: true) | |
|> Enum.map(fn | |
"anonymous fn" <> _rest = row -> | |
[anonymous_fn, rest] = | |
String.split(row, ~r{anonymous fn/\d+ in .*/\d+}, trim: true, include_captures: true) | |
[anonymous_fn] ++ String.split(rest, ~r/\s/, trim: true) | |
row -> | |
String.split(row, ~r/\s/, trim: true) | |
end) | |
|> Enum.map(& Enum.join(&1, ", ")) | |
|> Enum.join("\n") | |
|> then(& File.write!("results.csv", &1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment