fgmacedo / python-statemachine

Python Finite State Machines made easy.
MIT License
854 stars 84 forks source link

Unifying callbacks setup with the observer machinery #427

Closed fgmacedo closed 4 months ago

fgmacedo commented 5 months ago

Got faster setup by a factor of ~1.8x, and a much simpler callback machinery.

image

------------------------------------------------------------------------------------------------ benchmark: 2 tests ------------------------------------------------------------------------------------------------
Name (time in us)                              Min                 Max                Mean             StdDev              Median                IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_setup_performance (NOW)              454.0735 (1.0)      483.1138 (1.0)      469.9761 (1.0)       8.3577 (1.0)      470.2344 (1.0)       8.9441 (1.0)           3;0        2.1278 (1.0)          10        1000
test_setup_performance (0001_9d177b2)     803.6698 (1.77)     837.5716 (1.73)     818.7163 (1.74)     10.4420 (1.25)     817.8931 (1.74)     11.7049 (1.31)          4;0        1.2214 (0.57)         10        1000
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Changes

  1. Removing the ._setup() extra call;
  2. Unifying the callbacks registry with the observer machinery.
  3. Reducing complexity;

Complements the work done on #425.

TODO:

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (16f2a73) to head (1d39a99).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #427 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 20 20 Lines 1144 1174 +30 Branches 164 166 +2 ========================================= + Hits 1144 1174 +30 ``` | [Flag](https://app.codecov.io/gh/fgmacedo/python-statemachine/pull/427/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Fernando+Macedo) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/fgmacedo/python-statemachine/pull/427/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Fernando+Macedo) | `100.00% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Fernando+Macedo#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud