Skip to content

Fix QueryStatistics.ExecutionAvgTime calculation #2968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 11, 2022

Conversation

maikschott
Copy link
Contributor

QueryStatistics.ExecutionAvgTime was incorrectly calculated.

Assuming a query first took 10ms and then 30ms, the average between both should be 20ms.
However, the old implementation was newAvgTime = (oldAvgTime * n + curTime) / n which in the provided example would result in (10*2+30)/2 = 50/2 = 25.

As the old average time was calculated on (n-1) samples the first instance of n should be n-1 instead, which correctly results in (10*(2-1)+30)/2 = 40/2 = 20.

@hazzik hazzik changed the title QueryStatistics.ExecutionAvgTime is now correctly calculated Fix QueryStatistics.ExecutionAvgTime calculation Jan 10, 2022
@hazzik hazzik enabled auto-merge (squash) January 10, 2022 20:17
@hazzik hazzik added this to the next minor milestone Jan 10, 2022
hazzik
hazzik previously approved these changes Jan 10, 2022
@bahusoid
Copy link
Member

Seems async regen is needed for tests

@bahusoid bahusoid disabled auto-merge January 11, 2022 06:37
@hazzik
Copy link
Member

hazzik commented Jan 11, 2022

@bahusoid thanks. Done.

@hazzik hazzik enabled auto-merge (squash) January 11, 2022 08:53
@hazzik hazzik merged commit a14c19e into nhibernate:master Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants