Skip to content

Commit 79105a0

Browse files
authored
feat: update README.md status badges and improve TestFastEnforcer() (#396)
BREAKING CHANGE: this work for release PyCasbin v2 * docs: change status badge fix: #395 * test: the performance test is fuzzy, measure multiple times and compare the average values. * docs: Update README.md status badge
1 parent ef44178 commit 79105a0

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
PyCasbin
22
====
33

4-
[![GitHub Action](https://github.com/casbin/pycasbin/workflows/build/badge.svg?branch=master)](https://github.com/casbin/pycasbin/actions)
4+
[![build](https://github.com/casbin/pycasbin/actions/workflows/build.yml/badge.svg)](https://github.com/casbin/pycasbin/actions/workflows/build.yml)
55
[![Coverage Status](https://coveralls.io/repos/github/casbin/pycasbin/badge.svg)](https://coveralls.io/github/casbin/pycasbin)
66
[![Version](https://img.shields.io/pypi/v/pycasbin.svg)](https://pypi.org/project/pycasbin/)
77
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/pycasbin.svg)](https://pypi.org/project/pycasbin/)
88
[![Pyversions](https://img.shields.io/pypi/pyversions/pycasbin.svg)](https://pypi.org/project/pycasbin/)
9-
[![Download](https://img.shields.io/pypi/dm/pycasbin.svg)](https://pypi.org/project/pycasbin/)
9+
[![Download](https://static.pepy.tech/badge/pycasbin)](https://pypi.org/project/pycasbin/)
1010
[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN)
1111

1212
<p align="center">

tests/test_fast_enforcer.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ def test_performance(self) -> None:
4646
get_examples("performance/rbac_with_pattern_large_scale_policy.csv"),
4747
[2, 1],
4848
)
49-
s_e1 = time.perf_counter()
50-
e1.enforce("alice", "data1", "read")
51-
t_e1 = time.perf_counter() - s_e1
52-
s_e2 = time.perf_counter()
53-
e2.enforce("alice", "data1", "read")
54-
t_e2 = time.perf_counter() - s_e2
55-
assert t_e1 > t_e2 * 5
49+
N = 5
50+
t_e1_list = []
51+
t_e2_list = []
52+
for _ in range(N):
53+
s_e1 = time.perf_counter()
54+
e1.enforce("alice", "data1", "read")
55+
t_e1_list.append(time.perf_counter() - s_e1)
56+
s_e2 = time.perf_counter()
57+
e2.enforce("alice", "data1", "read")
58+
t_e2_list.append(time.perf_counter() - s_e2)
59+
avg_t_e1 = sum(t_e1_list) / N
60+
avg_t_e2 = sum(t_e2_list) / N
61+
assert avg_t_e1 > avg_t_e2 * 5
5662

5763
def test_creates_proper_policy(self) -> None:
5864
e = self.get_enforcer(

0 commit comments

Comments
 (0)