JuliaAstro / FITSIO.jl

Flexible Image Transport System (FITS) file support for Julia
http://juliaastro.org/FITSIO.jl/
MIT License
55 stars 29 forks source link

Reduce allocations in read! if ndims don't match #165

Closed jishnub closed 2 years ago

jishnub commented 2 years ago

The PR is best viewed by ignoring the whitespace fixes. The main changes are in https://github.com/JuliaAstro/FITSIO.jl/commit/f9445c755e89cad435393316c24789ec606dd5b1

On master

julia> f = tempname()
"/tmp/jl_06nrxc"

julia> FITSIO.fitswrite(f, Float64[1 2; 3 4]);

julia> ff = FITS(f, "r");

julia> v = zeros(4);

julia> @btime read!($(ff[1]), $v);
  640.083 ns (5 allocations: 384 bytes)

After this PR

julia> @btime read!($(ff[1]), $v);
  541.556 ns (4 allocations: 288 bytes)
codecov[bot] commented 2 years ago

Codecov Report

Merging #165 (b84dbbd) into master (47daa8b) will increase coverage by 0.17%. The diff coverage is 100.00%.

:exclamation: Current head b84dbbd differs from pull request most recent head f9445c7. Consider uploading reports for the commit f9445c7 to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage   91.02%   91.20%   +0.17%     
==========================================
  Files           5        5              
  Lines         613      614       +1     
==========================================
+ Hits          558      560       +2     
+ Misses         55       54       -1     
Impacted Files Coverage Δ
src/image.jl 94.89% <100.00%> (+0.77%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 47daa8b...f9445c7. Read the comment docs.