Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
6746c65b
Unverified
Commit
6746c65b
authored
May 28, 2020
by
Chris Jones
Committed by
GitHub
May 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose `SkipWithError` in Python bindings. (#968)
parent
9284e90f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
benchmark.cc
bindings/python/benchmark/benchmark.cc
+2
-1
example.py
bindings/python/benchmark/example.py
+9
-0
No files found.
bindings/python/benchmark/benchmark.cc
View file @
6746c65b
...
@@ -42,6 +42,7 @@ PYBIND11_MODULE(_benchmark, m) {
...
@@ -42,6 +42,7 @@ PYBIND11_MODULE(_benchmark, m) {
py
::
class_
<
benchmark
::
State
>
(
m
,
"State"
)
py
::
class_
<
benchmark
::
State
>
(
m
,
"State"
)
.
def
(
"__bool__"
,
&
benchmark
::
State
::
KeepRunning
)
.
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
}
// namespace
bindings/python/benchmark/example.py
View file @
6746c65b
...
@@ -28,5 +28,14 @@ def sum_million(state):
...
@@ -28,5 +28,14 @@ def sum_million(state):
sum
(
range
(
1
_000_000
))
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__'
:
if
__name__
==
'__main__'
:
benchmark
.
main
()
benchmark
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment