-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Pycasbin benchmark #199
Conversation
Signed-off-by: stonex <[email protected]>
@EmperorYP7 @divy9881 @noob20000405 please review |
@EmperorYP7 plz review |
@@ -82,6 +82,12 @@ def isAuthorized(req): | |||
|
|||
Rest of the method's name is on par with `casbin-cpp`. | |||
|
|||
### Benchmark | |||
|
|||
Pycasbin use `pytest` for benchmark. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pycasbin use `pytest` for benchmark. | |
Pycasbin use `pytest` for benchmark. | |
`pip3 install -U pytest` |
|
||
Pycasbin use `pytest` for benchmark. | ||
|
||
Install `pytest` and `pycasbin` in your local machine, then run the benchmark by `python3 -m pytest --benchmark-verbose --benchmark-columns=mean,stddev,iqr,ops,rounds casbin-cpp/pycasbin/benchmarks/benchmark_model.py`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this instead:
python3 -m pytest --benchmark-verbose --benchmark-columns=mean,stddev,iqr,ops,rounds casbin-cpp/pycasbin/benchmarks/benchmark_model.py
e.enforce("user501", "data9", "read") | ||
|
||
|
||
# TODO: pycasbin cost too much time in large model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it crash often?
How about we set up a flag through an OS env variable for intensive testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cost too much time in my machine, don't crash.
Flagging these data types as opaque might be one way to go.
Let's perform profiling on the current casbin-cpp and pycasbin setup. I suspect casbin-cpp's performance majorly depends on the performance of the underlying library used. (Exprtk) There are scopes for micro-optimizations that I can think of. We'd need a thorough look into the code to create a significant difference in performance. |
@sheny1xuan in the first set of timing numbers, the stddev is greater than the mean. This usually indicates invalid stats or the possibility of at least a bimodal (or more) distribution. |
Oh, I only paid attention to the mean, the stddev is also very important in the benchmark. And the above comparison of pycasbin and casbin-cpp binding is valid. The two set of benchmark data is all about casbin-cpp binding, I forget to change the package install environment. |
DataVector
andDataList
with python will be helpful. We can ref to https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html.