Skip to content

compare variance instead of std#38289

Open
therepanic wants to merge 3 commits into
commaai:masterfrom
therepanic:compare-variance-instead-of-std
Open

compare variance instead of std#38289
therepanic wants to merge 3 commits into
commaai:masterfrom
therepanic:compare-variance-instead-of-std

Conversation

@therepanic

@therepanic therepanic commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

By removing the use of sqrt, we can speed up the class's operation, as the function is monotonic. Since variance >= 0, we need not worry about regressions.

------------------------------------------------------------------------------------------------------ benchmark: 4 tests -----------------------------------------------------------------------------------------------------
Name (time in ms)                                             Min                 Max                Mean             StdDev              Median                IQR            Outliers       OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_running_stat_filter_100k_updates (0001_std-bas)     222.7962 (41.84)    277.9288 (22.63)    236.1354 (35.89)    10.0290 (19.10)    234.3810 (42.97)    12.6640 (37.14)        11;1    4.2349 (0.03)         50           1
test_running_stat_filter_100k_updates (NOW)               53.5872 (10.06)     63.8374 (5.20)      56.5587 (8.60)      2.7103 (5.16)      55.4977 (10.17)     3.7500 (11.00)        10;0   17.6807 (0.12)         50           1
test_running_stat_filter_10k_updates (0001_std-bas)       21.6506 (4.07)      23.6699 (1.93)      22.3316 (3.39)      0.5252 (1.0)       22.1995 (4.07)      0.6961 (2.04)         14;0   44.7796 (0.29)         50           1
test_running_stat_filter_10k_updates (NOW)                 5.3251 (1.0)       12.2828 (1.0)        6.5792 (1.0)       2.1874 (4.16)       5.4549 (1.0)       0.3410 (1.0)          8;12  151.9939 (1.0)          50           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
================================================== 2 passed in 3.21s ==================================================

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Process replay diff report

Replays driving segments through this PR and compares the behavior to master.
Please review any changes carefully to ensure they are expected.

✅ 0 changed, 66 passed, 0 errors

Comment on lines -48 to -50
def std(self):
return np.sqrt(self.variance())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unused method

@therepanic

Copy link
Copy Markdown
Contributor Author

The build error is related to #38286

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant