Skip to content

feat: dynamic sampling time#27

Merged
nazarhussain merged 3 commits intomainfrom
nh/cofficient-logic-update
Jan 29, 2025
Merged

feat: dynamic sampling time#27
nazarhussain merged 3 commits intomainfrom
nh/cofficient-logic-update

Conversation

@nazarhussain
Copy link
Copy Markdown

Motivation

Implement dynamic sampling time

Description

  • When benchmark runs very fast in few nano seconds or ms
  • It accumulate a lot of runs before we calculate CV
  • That huge number of sampling can cause noise
  • So we reduce the sampling interval dynamically if the function runs very fast

Steps to test or reproduce

  • Run all tests

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 29, 2025

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 8b7ddc0 Previous: null Ratio
sum array with raw for loop 933.64 us/op
sum array with reduce 10.249 ms/op
sum array with reduce beforeEach 82.142 us/op
sum array with reduce before beforeEach 8.0500 us/op
sum array with reduce high threshold 10.203 ms/op
sum array with reduce no threshold 10.633 ms/op

by benchmarkbot/action

Comment on lines +35 to +39
if (timeSinceLastCheck < sampleEveryMs) {
// If last call was wade 50% faster than the sampleEveryMs, let's reduce the sample interval to 10%
if (sampleEveryMs > 2 && sampleEveryMs / 2 > timeSinceLastCheck) {
sampleEveryMs -= sampleEveryMs * 0.1;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is the dynamic logic to reduce the sampling interval.

@nazarhussain nazarhussain merged commit e166eb9 into main Jan 29, 2025
@nazarhussain nazarhussain deleted the nh/cofficient-logic-update branch January 29, 2025 20:21
This was referenced Apr 30, 2025
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