Benchmarks
- Go
- Python
- C++
- Lua (JIT)
The overhead of policy enforcement has been benchmarked in model_b_test.go. The testbed configuration is as follows:
英特尔 酷睿 i7-6700HQ CPU @ 2.60GHz, 2601 Mhz, 4 核, 8 处理器
Following are the benchmarking results obtained by running go test -bench=. -benchmem
(op = an Enforce()
call, ms = millisecond, KB = kilobytes):
测试用例 | 规则大小 | 时间开销 (ms/op) | 内存开销 (KB) |
---|---|---|---|
ACL | 2 规则 (2用户) | 0.015493 | 5.649 |
RBAC | 5条规则 (2用户,1个角色) | 0.021738 | 7.522 |
RBAC (小型) | 1100条规则 (1000用户,100个角色) | 0.164309 | 80.620 |
RBAC (中型) | 11000条规则 (10000用户,1000个角色) | 2.258262 | 765.152 |
RBAC (大型) | 110000条规则 (100000用户,10000个角色) | 23.916776 | 7606 |
具有资源角色的RBAC | 6条规则 (2用户,2个角色) | 0.021146 | 7.906 |
带有域/租户的RBAC | 6 条规则 (2个用户,1个角色,2个域) | 0.032696 | 10.755 |
ABAC | 0 规则 (0用户) | 0.007510 | 2.328 |
RESTful | 5 规则 (3用户) | 0.045398 | 91.774 |
拒绝改写 | 6条规则 (2用户,1个角色) | 0.023281 | 8.370 |
优先级 | 9条规则 (2用户,2个角色) | 0.016389 | 5.313 |
The overhead of policy enforcement in Pycasbin has been benchmarked in the tests/benchmarks
directory. The testbed configuration is as follows:
Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz (Runned by Github actions)
platform linux -- Python 3.11.4, pytest-7.0.1, pluggy-1.2.0
Here are the benchmarking results obtained from executing casbin_benchmark
(op = an enforce()
call, ms = millisecond):
测试用例 | 规则大小 | 时间开销 (ms/op) |
---|---|---|
ACL | 2 规则 (2用户) | 0.067691 |
RBAC | 5条规则 (2用户,1个角色) | 0.080045 |
RBAC (小型) | 1100条规则 (1000用户,100个角色) | 0.853590 |
RBAC (中型) | 11000条规则 (10000用户,1000个角色) | 6.986668 |
RBAC (大型) | 110000条规则 (100000用户,10000个角色) | 77.922851 |
具有资源角色的RBAC | 6条规则 (2用户,2个角色) | 0.106090 |
带有域/租户的RBAC | 6 条规则 (2个用户,1个角色,2个域) | 0.103628 |
ABAC | 0 规则 (0用户) | 0.053213 |
RESTful | 5 规则 (3用户) | NA |
拒绝改写 | 6条规则 (2用户,1个角色) | NA |
优先级 | 9条规则 (2用户,2个角色) | 0.084684 |
The overhead of policy enforcement in Casbin CPP has been benchmarked in the tests/benchmarks
directory using Google's benchmarking tool. The testbed configuration is as follows:
英特尔 酷睿 i5-6300HQ CPU @ 2.30GHz, 4 核, 4 线程
Here are the benchmarking results obtained from executing the casbin_benchmark
target built in the Release
configuration (op = an enforce()
call, ms = millisecond):
测试用例 | 规则大小 | 时间开销 (ms/op) |
---|---|---|
ACL | 2 规则 (2用户) | 0.0195 |
RBAC | 5条规则 (2用户,1个角色) | 0.0288 |
RBAC (小型) | 1100条规则 (1000用户,100个角色) | 0.300 |
RBAC (中型) | 11000条规则 (10000用户,1000个角色) | 2.113 |
RBAC (大型) | 110000条规则 (100000用户,10000个角色) | 21.450 |
具有资源角色的RBAC | 6条规则 (2用户,2个角色) | 0.03 |
带有域/租户的RBAC | 6 条规则 (2个用户,1个角色,2个域) | 0.041 |
ABAC | 0 规则 (0用户) | NA |
RESTful | 5 规则 (3用户) | NA |
拒绝改写 | 6条规则 (2用户,1个角色) | 0.0246 |
优先级 | 9条规则 (2用户,2个角色) | 0.035 |
The overhead of policy enforcement in Lua Casbin has been benchmarked in bench.lua. The testbed configuration is as follows:
AMD Ryzen(TM) 5 4600H CPU @ 3.0GHz, 6 核, 12 Threads
Here are the benchmarking results obtained by running luajit bench.lua
(op = an enforce()
call, ms = millisecond):
Test case | Rule size | Time overhead (ms/op) |
---|---|---|
ACL | 2 rules (2 users) | 0.0533 |
RBAC | 5 rules (2 users, 1 role) | 0.0972 |
RBAC (small) | 1100 rules (1000 users, 100 roles) | 0.8598 |
RBAC (medium) | 11000 rules (10000 users, 1000 roles) | 8.6848 |
RBAC (large) | 110000 rules (100000 users, 10000 roles) | 90.3217 |
RBAC with resource roles | 6 rules (2 users, 2 roles) | 0.1124 |
RBAC with domains/tenants | 6 rules (2 users, 1 role, 2 domains) | 0.1978 |
ABAC | 0 rule (0 user) | 0.0305 |
RESTful | 5 rules (3 users) | 0.1085 |
Deny-override | 6 rules (2 users, 1 role) | 0.1934 |
Priority | 9 rules (2 users, 2 roles) | 0.1437 |
Benchmark monitoring
In the embedded web page below, you can see the performance changes of Casbin for each commit.
You can also directly browse it at: https://v1.casbin.org/casbin/benchmark-monitoring