bankofcanada / StateSpaceEcon.jl

BSD 3-Clause "New" or "Revised" License
49 stars 9 forks source link

Shift creation of sparse matrix out one level #42

Closed KristofferC closed 1 year ago

KristofferC commented 1 year ago

The current location of the sparse matrix creation seems to create new sparse matrix for every unknown. But the location of where the sparse matrix is created is overwritten in every iteration so only the last sparse matrix will survive. It should therefore be equivalent to only create the sparse matrix once, outside the loop.

Previously, in a simulation there were 768 calls to sparse

 Section            ncalls     time    %tot     avg     alloc    %tot      avg
 ────────────────────────────────────────────────────────────────────────────
   sparse              768    152ms   26.2%   198μs    557MiB   50.3%   743KiB

and after this there is only one.

 Section            ncalls     time    %tot     avg     alloc    %tot      avg
 ────────────────────────────────────────────────────────────────────────────
   sparse                1   64.1μs    0.0%  64.1μs    743KiB    0.1%   743KiB
codecov-commenter commented 1 year ago

Codecov Report

Merging #42 (9eadc95) into master (a9a9de5) will not change coverage. The diff coverage is 100.00%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##           master      #42   +/-   ##
=======================================
  Coverage   88.25%   88.25%           
=======================================
  Files          24       24           
  Lines        1924     1924           
=======================================
  Hits         1698     1698           
  Misses        226      226           
Impacted Files Coverage Δ
src/stackedtime/solverdata.jl 98.95% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.