JuliaCI / Coverage.jl

Take Julia code coverage and memory allocation results, do useful things with them
MIT License
174 stars 68 forks source link

Add report allocs function #337

Closed charleskawczynski closed 1 year ago

charleskawczynski commented 1 year ago

This PR:

This function was ported over from ReportMetrics.jl.

Here is an example usage, which was also added to the docs / readme:

julia> import Coverage
julia> import PrettyTables # load report_allocs
julia> mktempdir() do path
           open(joinpath(path, "example.jl"), "w") do io
               println(io, "for i in 1:1000")
               println(io, "    x = []")
               println(io, "    push!(x, 1)")
               println(io, "    push!(x, [1,2,3,4])")
               println(io, "    push!(x, \"stringy-string\")")
               println(io, "end")
           end
           Coverage.report_allocs(;
               run_cmd=`$(Base.julia_cmd()) --track-allocation=all $(joinpath(path, "example.jl"))`,
               dirs_to_monitor = [path],
               process_filename = fn -> replace(fn, path=>""),
           )
       end
3 unique allocating sites, 224000 total bytes
┌──────────────────────┬─────────────┬───────────────┐
│ <file>:<line number> │ Allocations │ Allocations % │
│                      │   (bytes)   │    (xᵢ/∑x)    │
├──────────────────────┼─────────────┼───────────────┤
│ example.jl:4         │    96000    │      43       │
│ example.jl:3         │    80000    │      36       │
│ example.jl:2         │    48000    │      21       │
└──────────────────────┴─────────────┴───────────────┘
coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 3991864528


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/report_allocs.jl 59 79 74.68%
<!-- Total: 62 82 75.61% -->
Files with Coverage Reduction New Missed Lines %
src/codecovio.jl 2 87.39%
src/coveralls.jl 2 94.74%
<!-- Total: 4 -->
Totals Coverage Status
Change from base Build 3679300279: -3.7%
Covered Lines: 268
Relevant Lines: 308

💛 - Coveralls
codecov[bot] commented 1 year ago

Codecov Report

Merging #337 (0daf25a) into master (453ba9f) will decrease coverage by 3.33%. The diff coverage is 76.82%.

@@            Coverage Diff             @@
##           master     #337      +/-   ##
==========================================
- Coverage   90.66%   87.33%   -3.33%     
==========================================
  Files           2        4       +2     
  Lines         225      308      +83     
==========================================
+ Hits          204      269      +65     
- Misses         21       39      +18     
Impacted Files Coverage Δ
src/report_allocs.jl 75.94% <75.94%> (ø)
src/Coverage.jl 100.00% <100.00%> (ø)
src/coveralls.jl 94.73% <0.00%> (-1.76%) :arrow_down:
src/codecovio.jl 87.38% <0.00%> (+2.70%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

charleskawczynski commented 1 year ago

Bump!

charleskawczynski commented 1 year ago

Bump!

charleskawczynski commented 1 year ago

Closing in light of https://github.com/JuliaLang/julia/pull/48070.