Unverified Commit 6746c65b by Chris Jones Committed by GitHub

Expose `SkipWithError` in Python bindings. (#968)

parent 9284e90f
......@@ -42,6 +42,7 @@ PYBIND11_MODULE(_benchmark, m) {
py::class_<benchmark::State>(m, "State")
.def("__bool__", &benchmark::State::KeepRunning)
.def_property_readonly("keep_running", &benchmark::State::KeepRunning);
.def_property_readonly("keep_running", &benchmark::State::KeepRunning)
.def("skip_with_error", &benchmark::State::SkipWithError);
};
} // namespace
......@@ -28,5 +28,14 @@ def sum_million(state):
sum(range(1_000_000))
@benchmark.register
def skipped(state):
if True: # Test some predicate here.
state.skip_with_error('some error')
return # NOTE: You must explicitly return, or benchmark will continue.
... # Benchmark code would be here.
if __name__ == '__main__':
benchmark.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment