Skip to content

Commit

Permalink
Add pie chart example
Browse files Browse the repository at this point in the history
  • Loading branch information
VarLad committed May 11, 2024
1 parent 550a8ec commit f514978
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 858 deletions.
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
CoverageTools = "c36e975a-824b-4404-a568-ef97ca766997"
CpuId = "adafc99b-e345-5852-983c-f28acb93d879"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Expand All @@ -17,16 +18,19 @@ TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
[weakdeps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[extensions]
BenchmarkToolsExt = "BenchmarkTools"
ChairmarksExt = "Chairmarks"
MakieExt = "Makie"

[compat]
BenchmarkTools = "1.5"
Chairmarks = "1.2"
CoverageTools = "1"
CpuId = "0.3.1"
Makie = "0.20"
TypedTables = "1"
julia = "1"

Expand Down
8 changes: 8 additions & 0 deletions ext/MakieExt/MakieExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module MakieExt

using Makie
using TypedTables
using PerfChecker
include("plotutils.jl")

end
42 changes: 42 additions & 0 deletions ext/MakieExt/plotutils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
make_colors(l) = Makie.distinguishable_colors(l, [Makie.RGB(1, 1, 1), Makie.RGB(0, 0, 0)], dropseed=true)

function smart_paths(paths)
splitted_paths = map(splitpath normpath, paths)

common = paths |> first |> dirname |> splitpath
for path in splitted_paths
to_pop = length(common)
for name in Iterators.zip(common, path)
name[1] == name[2] || break
to_pop -= 1
end
foreach(_ -> pop!(common), 1:to_pop)
end

for path in splitted_paths
foreach(_ -> popfirst!(path), 1:length(common))
end

return joinpath(common...), map(joinpath, splitted_paths)
end

function PerfChecker.table_to_pie(x::Table, ::Val{:alloc})
data = x.bytes
@info data
paths = smart_paths(x.filenames)[2] .* " " .* string.(x.linenumbers)
percentage = data .* 100 ./ sum(data)
@info percentage
colors = make_colors(length(percentage))
f, ax, plt = pie(data,
color = colors,
radius = 4,
inner_radius = 2,
strokecolor = :white,
strokewidth = 5,
axis = (autolimitaspect = 1, ),
)
hidedecorations!(ax);
hidespines!(ax)
Legend(f[1,2], [PolyElement(color=c) for c in colors], paths)
f
end
856 changes: 0 additions & 856 deletions perf/GLM/benchmarks/benchmark-memory.tikz

This file was deleted.

2 changes: 2 additions & 0 deletions perf/PatternFolds/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
CoverageTools = "c36e975a-824b-4404-a568-ef97ca766997"
PatternFolds = "c18a7f1d-76ad-4ce4-950d-5419b888513b"
PerfChecker = "6309bf6b-a531-4b08-891e-8ee981e5c424"
3 changes: 2 additions & 1 deletion perf/PatternFolds/allocs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using PerfChecker
using PerfChecker, CairoMakie

d = Dict(:targets => ["PatternFolds"], :path => @__DIR__, :tags => [:patterns, :intervals], :pkgs => ("PatternFolds", :custom, [v"0.2.3", v"0.2.2"], true))

Expand Down Expand Up @@ -27,3 +27,4 @@ x = @check :alloc d begin
end

@info x
display(table_to_pie(x.tables[1], Val(:alloc)))
1 change: 1 addition & 0 deletions src/PerfChecker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export @check
export to_table
export find_by_tags
export get_versions
export table_to_pie

# SECTION - Includes
include("versions.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/alloc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function post(d::Dict, ::Val{:alloc})
result = d[:check_result]
files = find_malloc_files(result[1])
delete_files = find_malloc_files(result[2])
myallocs = analyze_malloc_files(files)
myallocs = analyze_malloc_files(files; skip_zeros=true)
if !isempty(myallocs)
rm.(delete_files)
else
Expand Down
2 changes: 2 additions & 0 deletions src/check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ end
function perf_table end

function perf_plot end

function table_to_pie end

0 comments on commit f514978

Please sign in to comment.