elise1993 / sysidHAVOK

This is a testbed for system identification and forecasting of dynamical systems using the Hankel Alternative View of Koopman (HAVOK) algorithm and Sparse Identification of Nonlinear Dynamics (SINDy). This code is based on the work by Brunton & Kutz (2022) and Yang et. al. (2022).
MIT License
1 stars 0 forks source link

Test 3: Performance #18

Open elise1993 opened 6 months ago

elise1993 commented 6 months ago

The following performance optimization strategies have been employed in this code:

Unit Tests

The subcomponents of this code are quite simple and required minimal testing to verify their correctness. The functions will throw an error if the wrong type of input is provided, as specified by the arguments tab in each function.

We check the performance of the units using MATLAB's Performance Testing Framework. This framework systematically tests each function's execution time, robustness to input noise, etc.

The tests are performed by constructing a test file, which looks like:

This testing framework is quite sensitive, as we can see by including a tiny probability (0.0000001% chance) of an error occurring in the code:

function H = HankelMatrix(x,stackmax)
%HankelMatrix Arrange a Hankel matrix

n = length(x);
ij = (1:n-stackmax) + (0:(stackmax-1))';
H = x(ij);

if rand > 0.999999
    error("something went wrong!")
end
runperf("tests/preallocationTest.m")

Done preallocationTest
__________

Failure Summary:

     Name                            Failed  Incomplete  Reason(s)
    ===============================================================
     preallocationTest/HankelMatrix    X         X       Errored.

results = 

  [TimeResult](matlab:helpPopup matlab.perftest.TimeResult) with properties:

            Name: 'preallocationTest/HankelMatrix'
           Valid: 0
         Samples: [49×7 table]
    TestActivity: [54×12 table]

Totals:
   0 Valid, 1 Invalid.
   3.4134 seconds testing time.

Regression Tests

Integration Tests

Coverage

We check that all parts of the code are covered using MATLAB's Code Coverage Plugin: