Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
profiler: add hooks to override functions for testing (#1259)
The profiler uses global startCPUProfile/stopCPUProfile/lookupProfile functions that are overridden by tests. Any test that wants to override these functions has to reset them. This results in duplicated code, and can cause difficult-to-understand issues if a new test is added that overrides the values and fails to reset them. For example, this has contributed to race conditions in our unit tests that are unrelated to actual bugs in our code. See PR #1255 for example. Having bugs in our tests makes it more difficult to diagnose real bugs in our code. Instead of having global values, add override hooks to the profiler struct that can be set during tests and fall back to the default behavior if no hooks are set. So long as each test uses its own profiler struct, each test can set its own hooks without affecting any other test.
- Loading branch information
Showing
4 changed files
with
58 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters