run ClearRegisteredBenchmarks at exit (#1463)

This commit is contained in:
Dominic Hamon 2022-08-08 13:34:20 -07:00 committed by GitHub
parent a476d0fd8e
commit af32e3fe1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -26,6 +26,7 @@ Example usage:
if __name__ == '__main__':
benchmark.main()
"""
import atexit
from absl import app
from google_benchmark import _benchmark
@ -158,3 +159,4 @@ def main(argv=None):
# Methods for use with custom main function.
initialize = _benchmark.Initialize
run_benchmarks = _benchmark.RunSpecifiedBenchmarks
atexit.register(_benchmark.ClearRegisteredBenchmarks)

View File

@ -179,5 +179,6 @@ PYBIND11_MODULE(_benchmark, m) {
py::return_value_policy::reference);
m.def("RunSpecifiedBenchmarks",
[]() { benchmark::RunSpecifiedBenchmarks(); });
m.def("ClearRegisteredBenchmarks", benchmark::ClearRegisteredBenchmarks);
};
} // namespace