diff --git a/.history/tests/benchmarks/CMakeLists_20211101203933.txt b/.history/tests/benchmarks/CMakeLists_20211101203933.txt deleted file mode 100644 index c6a34302..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211101203933.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102223225.txt b/.history/tests/benchmarks/CMakeLists_20211102223225.txt deleted file mode 100644 index 25a0e5f8..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102223225.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - enforcer_cached_b_inten.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102223453.txt b/.history/tests/benchmarks/CMakeLists_20211102223453.txt deleted file mode 100644 index 863ecac7..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102223453.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102223553.txt b/.history/tests/benchmarks/CMakeLists_20211102223553.txt deleted file mode 100644 index 25a0e5f8..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102223553.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - enforcer_cached_b_inten.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102224815.txt b/.history/tests/benchmarks/CMakeLists_20211102224815.txt deleted file mode 100644 index 25a0e5f8..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102224815.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - enforcer_cached_b_inten.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230417.txt b/.history/tests/benchmarks/CMakeLists_20211102230417.txt deleted file mode 100644 index 36dd9f6d..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230417.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - enforcer_cached_b_inten.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230421.txt b/.history/tests/benchmarks/CMakeLists_20211102230421.txt deleted file mode 100644 index e0169b18..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230421.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230439.txt b/.history/tests/benchmarks/CMakeLists_20211102230439.txt deleted file mode 100644 index c3ae1fcd..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230439.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230457.txt b/.history/tests/benchmarks/CMakeLists_20211102230457.txt deleted file mode 100644 index dfa16403..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230457.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230511.txt b/.history/tests/benchmarks/CMakeLists_20211102230511.txt deleted file mode 100644 index 042e5b75..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230511.txt +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230816.txt b/.history/tests/benchmarks/CMakeLists_20211102230816.txt deleted file mode 100644 index 661b1a41..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230816.txt +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") -add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230857.txt b/.history/tests/benchmarks/CMakeLists_20211102230857.txt deleted file mode 100644 index d7e30297..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230857.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102230905.txt b/.history/tests/benchmarks/CMakeLists_20211102230905.txt deleted file mode 100644 index 60d43a87..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102230905.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102231030.txt b/.history/tests/benchmarks/CMakeLists_20211102231030.txt deleted file mode 100644 index 15ca8064..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102231030.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "ON") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102231345.txt b/.history/tests/benchmarks/CMakeLists_20211102231345.txt deleted file mode 100644 index 60d43a87..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102231345.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102231356.txt b/.history/tests/benchmarks/CMakeLists_20211102231356.txt deleted file mode 100644 index 15ca8064..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102231356.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "ON") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102231437.txt b/.history/tests/benchmarks/CMakeLists_20211102231437.txt deleted file mode 100644 index 5c49a3ac..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102231437.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "ON") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102231707.txt b/.history/tests/benchmarks/CMakeLists_20211102231707.txt deleted file mode 100644 index 20d24fdf..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102231707.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102232650.txt b/.history/tests/benchmarks/CMakeLists_20211102232650.txt deleted file mode 100644 index 20d24fdf..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102232650.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -set(INTENSIVE_BENCHMARK "OFF") - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102233051.txt b/.history/tests/benchmarks/CMakeLists_20211102233051.txt deleted file mode 100644 index 75df3df7..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102233051.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -option(INTENSIVE_BENCHMARK OFF) - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL "ON") - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/CMakeLists_20211102233105.txt b/.history/tests/benchmarks/CMakeLists_20211102233105.txt deleted file mode 100644 index 5a679a4c..00000000 --- a/.history/tests/benchmarks/CMakeLists_20211102233105.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2021 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_definitions(-DCASBIN_PROJECT_DIR=${CMAKE_SOURCE_DIR}) - -option(INTENSIVE_BENCHMARK OFF) - -set(CASBIN_BENCHMARK_SOURCE - main.cpp - model_b.cpp - enforcer_cached_b.cpp - management_api_b.cpp - role_manager_b.cpp -) - -set(CASBIN_INTENSIVE_BENCHMARK_SOURCE - model_b_inten.cpp - enforcer_cached_b_inten.cpp - management_api_b_inten.cpp - role_manager_b_inten.cpp -) - -set(CASBIN_BENCHMARK_HEADER - config_path.h -) - -if(INTENSIVE_BENCHMARK STREQUAL ON) - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_INTENSIVE_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -else() - add_executable(casbin_benchmark ${CASBIN_BENCHMARK_SOURCE} ${CASBIN_BENCHMARK_HEADER}) -endif() - -target_include_directories(casbin_benchmark PUBLIC ${CASBIN_INCLUDE_DIR}) - -if(UNIX) - set_target_properties(casbin_benchmark PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -endif() - -target_link_libraries( - casbin_benchmark - PRIVATE - benchmark - casbin -) diff --git a/.history/tests/benchmarks/enforcer_cached_b_20211101201615.cpp b/.history/tests/benchmarks/enforcer_cached_b_20211101201615.cpp deleted file mode 100644 index 70bd9bfe..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_20211101201615.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedBasicModel(benchmark::State& state) { - casbin::CachedEnforcer e(basic_model_path, basic_policy_path); - casbin::DataList request = {"alice", "data1", "read"}; - for (auto _ : state) - e.Enforce(request); -} - -BENCHMARK(BenchmarkCachedBasicModel); - - -static void BenchmarkCachedRBACModel(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, rbac_policy_path); - casbin::DataList request = {"alice", "data2", "read"}; - for (auto _ : state) - e.Enforce(request); -} - -BENCHMARK(BenchmarkCachedRBACModel); - -// ---- TODO ---- -// static void BenchmarkCachedRaw(benchmark::State& state) { -// for (auto _ : state) -// rawEnforce("alice", "data1", "read") -// } - -// BENCHMARK(BenchmarkCachedRaw); - -static void BenchmarkCachedRBACModelSmall(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - // 100 roles, 10 resources. - for (int i = 0; i < 100; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - // 1000 users. - for (int i = 0; i < 1000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group", std::to_string(i / 10) }); - casbin::DataList params = {"user501", "data9", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelSmall); - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -// BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -// BENCHMARK(BenchmarkCachedRBACModelLarge); - -static void BenchmarkCachedRBACModelWithResourceRoles(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_with_resource_roles_model_path, rbac_with_resource_roles_policy_path, false); - - casbin::DataList params = {"alice", "data1", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelWithResourceRoles); - -static void BenchmarkCachedRBACModelWithDomains(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_with_domains_model_path, rbac_with_domains_policy_path, false); - - casbin::DataList params = {"alice", "domain1", "data1", "read"}; - - for(auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelWithDomains); - -// ---- TODO ---- -// static void BenchmarkCachedABACModel(benchmark::State& state) { -// casbin::CachedEnforcer e(abac_model_path, false); -// auto data1 = casbin::GetData({ -// {"Name", "data1"}, -// {"Owner", "alice"} -// }); - -// casbin::DataList params = {"alice", data1, "read"}; -// for (auto _ : state) -// { -// e.Enforce(params); -// } -// } - -static void BenchmarkCachedKeyMatchModel(benchmark::State& state) { - casbin::CachedEnforcer e(keymatch_model_path, keymatch_policy_path, false); - casbin::DataList params = {"alice", "/alice_data/resource1", "GET"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedKeyMatchModel); - -static void BenchmarkCachedRBACModelWithDeny(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_with_deny_model_path, rbac_with_deny_policy_path, false); - - casbin::DataList params = {"alice", "data1", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelWithDeny); - -static void BenchmarkCachedPriorityModel(benchmark::State& state) { - casbin::CachedEnforcer e(priority_model_path, priority_policy_path, false); - - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedPriorityModel); - -static void BenchmarkCachedRBACModelMediumParallel(benchmark::State& state) { - - casbin::CachedEnforcer e(rbac_model_path, "", false); - casbin::DataList params = {"user5001", "data150", "read"}; - if (state.thread_index == 0) - { - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - e.AddPolicies(p_policies); - - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i/10) }); - } - for (auto _ : state) { - e.Enforce(params); - } -} -// BENCHMARK(BenchmarkCachedRBACModelMediumParallel)->Threads(10); - diff --git a/.history/tests/benchmarks/enforcer_cached_b_20211102234136.cpp b/.history/tests/benchmarks/enforcer_cached_b_20211102234136.cpp deleted file mode 100644 index 1c7dca67..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_20211102234136.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedBasicModel(benchmark::State& state) { - casbin::CachedEnforcer e(basic_model_path, basic_policy_path); - casbin::DataList request = {"alice", "data1", "read"}; - for (auto _ : state) - e.Enforce(request); -} - -BENCHMARK(BenchmarkCachedBasicModel); - - -static void BenchmarkCachedRBACModel(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, rbac_policy_path); - casbin::DataList request = {"alice", "data2", "read"}; - for (auto _ : state) - e.Enforce(request); -} - -BENCHMARK(BenchmarkCachedRBACModel); - -// ---- TODO ---- -// static void BenchmarkCachedRaw(benchmark::State& state) { -// for (auto _ : state) -// rawEnforce("alice", "data1", "read") -// } - -// BENCHMARK(BenchmarkCachedRaw); - -static void BenchmarkCachedRBACModelSmall(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - // 100 roles, 10 resources. - for (int i = 0; i < 100; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - // 1000 users. - for (int i = 0; i < 1000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group", std::to_string(i / 10) }); - casbin::DataList params = {"user501", "data9", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelSmall); - -static void BenchmarkCachedRBACModelWithResourceRoles(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_with_resource_roles_model_path, rbac_with_resource_roles_policy_path, false); - - casbin::DataList params = {"alice", "data1", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelWithResourceRoles); - -static void BenchmarkCachedRBACModelWithDomains(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_with_domains_model_path, rbac_with_domains_policy_path, false); - - casbin::DataList params = {"alice", "domain1", "data1", "read"}; - - for(auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelWithDomains); - -// ---- TODO ---- -// static void BenchmarkCachedABACModel(benchmark::State& state) { -// casbin::CachedEnforcer e(abac_model_path, false); -// auto data1 = casbin::GetData({ -// {"Name", "data1"}, -// {"Owner", "alice"} -// }); - -// casbin::DataList params = {"alice", data1, "read"}; -// for (auto _ : state) -// { -// e.Enforce(params); -// } -// } - -static void BenchmarkCachedKeyMatchModel(benchmark::State& state) { - casbin::CachedEnforcer e(keymatch_model_path, keymatch_policy_path, false); - casbin::DataList params = {"alice", "/alice_data/resource1", "GET"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedKeyMatchModel); - -static void BenchmarkCachedRBACModelWithDeny(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_with_deny_model_path, rbac_with_deny_policy_path, false); - - casbin::DataList params = {"alice", "data1", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelWithDeny); - -static void BenchmarkCachedPriorityModel(benchmark::State& state) { - casbin::CachedEnforcer e(priority_model_path, priority_policy_path, false); - - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedPriorityModel); diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223035.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223035.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223121.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223121.cpp deleted file mode 100644 index 103ff134..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223121.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223157.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223157.cpp deleted file mode 100644 index d5fb9ea7..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223157.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -// BENCHMARK(BenchmarkCachedRBACModelMedium); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223200.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223200.cpp deleted file mode 100644 index 163079b3..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102223200.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224120.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224120.cpp deleted file mode 100644 index e9bc5cb3..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224120.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -// BENCHMARK(BenchmarkCachedRBACModelLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224123.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224123.cpp deleted file mode 100644 index 258fba8b..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224123.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224201.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224201.cpp deleted file mode 100644 index 365efdeb..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224201.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelLarge); - -static void BenchmarkCachedRBACModelMediumParallel(benchmark::State& state) { - - casbin::CachedEnforcer e(rbac_model_path, "", false); - casbin::DataList params = {"user5001", "data150", "read"}; - if (state.thread_index == 0) - { - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - e.AddPolicies(p_policies); - - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i/10) }); - } - for (auto _ : state) { - e.Enforce(params); - } -} -// BENCHMARK(BenchmarkCachedRBACModelMediumParallel)->Threads(10); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224721.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224721.cpp deleted file mode 100644 index 7925e0f2..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102224721.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelLarge); - -static void BenchmarkCachedRBACModelMediumParallel(benchmark::State& state) { - - casbin::CachedEnforcer e(rbac_model_path, "", false); - casbin::DataList params = {"user5001", "data150", "read"}; - if (state.thread_index == 0) - { - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - e.AddPolicies(p_policies); - - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i/10) }); - } - for (auto _ : state) { - e.Enforce(params); - } -} -// BENCHMARK(BenchmarkCachedRBACModelMediumParallel)->Threads(10); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234001.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234001.cpp deleted file mode 100644 index ca731049..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234001.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelLarge); - -static void BenchmarkCachedRBACModelMediumParallel(benchmark::State& state) { - - casbin::CachedEnforcer e(rbac_model_path, "", false); - casbin::DataList params = {"user5001", "data150", "read"}; - if (state.thread_index == 0) - { - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - e.AddPolicies(p_policies); - - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i/10) }); - } - for (auto _ : state) { - e.Enforce(params); - } -} -BENCHMARK(BenchmarkCachedRBACModelMediumParallel)->Threads(10); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234125.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234125.cpp deleted file mode 100644 index ca731049..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234125.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelLarge); - -static void BenchmarkCachedRBACModelMediumParallel(benchmark::State& state) { - - casbin::CachedEnforcer e(rbac_model_path, "", false); - casbin::DataList params = {"user5001", "data150", "read"}; - if (state.thread_index == 0) - { - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - e.AddPolicies(p_policies); - - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i/10) }); - } - for (auto _ : state) { - e.Enforce(params); - } -} -BENCHMARK(BenchmarkCachedRBACModelMediumParallel)->Threads(10); \ No newline at end of file diff --git a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234201.cpp b/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234201.cpp deleted file mode 100644 index 7925e0f2..00000000 --- a/.history/tests/benchmarks/enforcer_cached_b_inten_20211102234201.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::CachedEnforcer -*/ - -#include -#include -#include "config_path.h" - -static void BenchmarkCachedRBACModelMedium(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - std::vector> p_policies(1000); - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - - e.AddPolicies(p_policies); - - // 10000 users. - std::vector> g_policies(10000); - for (int i = 0; i < 10000; ++i) - g_policies[i] = { "user" + std::to_string(i), "group" + std::to_string(i/10) }; - - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user5001", "data150", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkCachedRBACModelMedium); - -static void BenchmarkCachedRBACModelLarge(benchmark::State& state) { - casbin::CachedEnforcer e(rbac_model_path, "", false); - - // 10000 roles, 1000 resources. - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = {"group", std::to_string(i), "data", std::to_string(i / 10), "read"}; - e.AddPolicies(p_policies); - - // 100000 users. - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) { - g_policies[i] = {"user" + std::to_string(i), "group", std::to_string(i / 10)}; - } - e.AddGroupingPolicies(g_policies); - casbin::DataList params = {"user50001", "data1500", "read"}; - for (auto _ : state) - { - e.Enforce(params); - } -} - -BENCHMARK(BenchmarkCachedRBACModelLarge); - -static void BenchmarkCachedRBACModelMediumParallel(benchmark::State& state) { - - casbin::CachedEnforcer e(rbac_model_path, "", false); - casbin::DataList params = {"user5001", "data150", "read"}; - if (state.thread_index == 0) - { - std::vector> p_policies(10000); - for (int i = 0; i < 10000; ++i) - p_policies[i] = { "group" + std::to_string(i), "data" + std::to_string(i / 10), "read" }; - e.AddPolicies(p_policies); - - std::vector> g_policies(100000); - for (int i = 0; i < 100000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i/10) }); - } - for (auto _ : state) { - e.Enforce(params); - } -} -// BENCHMARK(BenchmarkCachedRBACModelMediumParallel)->Threads(10); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_20211101202720.cpp b/.history/tests/benchmarks/management_api_b_20211101202720.cpp deleted file mode 100644 index e508464c..00000000 --- a/.history/tests/benchmarks/management_api_b_20211101202720.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static inline int GetRandom100() -{ - return dist_100(generator); -} - -static inline int GetRandom1000() -{ - return dist_1000(generator); -} - -static inline int GetRandom10000() -{ - return dist_10000(generator); -} - -static void BenchmarkVectorOperations(benchmark::State& state) { - for(auto _ : state) - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000() / 10), "read"}; -} - -BENCHMARK(BenchmarkVectorOperations); - -static void BenchmarkHasPolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for (int i = 0; i < 100; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for (auto _ : state) - params = { "user" + std::to_string(GetRandom100()), "data" + std::to_string(GetRandom100()/10), "read" }, e.HasPolicy(params); -} - -BENCHMARK(BenchmarkHasPolicySmall); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -// BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -// BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for(int i = 0; i < 100; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i/10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = {"user" + std::to_string(GetRandom100() + 100), "data" + std::to_string((GetRandom100() + 100)/10), "read"}, e.AddPolicy(params); -} - -BENCHMARK(BenchmarkAddPolicySmall); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyMedium); - -static void BenchmarkAddPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i/10), "read" }, e.AddPolicy(params); - - for(auto _ : state) { - params = { "user" + std::to_string(GetRandom10000() + 10000), "data" + std::to_string((GetRandom10000() + 10000) / 10), "read" }, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyLarge); - -static void BenchmarkRemovePolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for(int i = 100; i < 100; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom100()), "data" + std::to_string(GetRandom100() / 10), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicySmall); - -static void BenchmarkRemovePolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000() / 10), "read" }, e.RemovePolicy(params); -} - -// BENCHMARK(BenchmarkRemovePolicyMedium); - -static void BenchmarkRemovePolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom1000()), "read" }, e.RemovePolicy(params); -} - -// BENCHMARK(BenchmarkRemovePolicyLarge); - diff --git a/.history/tests/benchmarks/management_api_b_20211102234229.cpp b/.history/tests/benchmarks/management_api_b_20211102234229.cpp deleted file mode 100644 index 99e6f23f..00000000 --- a/.history/tests/benchmarks/management_api_b_20211102234229.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static inline int GetRandom100() -{ - return dist_100(generator); -} - -static inline int GetRandom1000() -{ - return dist_1000(generator); -} - -static inline int GetRandom10000() -{ - return dist_10000(generator); -} - -static void BenchmarkVectorOperations(benchmark::State& state) { - for(auto _ : state) - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000() / 10), "read"}; -} - -BENCHMARK(BenchmarkVectorOperations); - -static void BenchmarkHasPolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for (int i = 0; i < 100; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for (auto _ : state) - params = { "user" + std::to_string(GetRandom100()), "data" + std::to_string(GetRandom100()/10), "read" }, e.HasPolicy(params); -} - -BENCHMARK(BenchmarkHasPolicySmall); - -static void BenchmarkAddPolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for(int i = 0; i < 100; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i/10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = {"user" + std::to_string(GetRandom100() + 100), "data" + std::to_string((GetRandom100() + 100)/10), "read"}, e.AddPolicy(params); -} - -BENCHMARK(BenchmarkAddPolicySmall); - -static void BenchmarkRemovePolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for(int i = 100; i < 100; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom100()), "data" + std::to_string(GetRandom100() / 10), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicySmall); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_20211102234231.cpp b/.history/tests/benchmarks/management_api_b_20211102234231.cpp deleted file mode 100644 index 7e479037..00000000 --- a/.history/tests/benchmarks/management_api_b_20211102234231.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static inline int GetRandom100() -{ - return dist_100(generator); -} - -static inline int GetRandom1000() -{ - return dist_1000(generator); -} - -static inline int GetRandom10000() -{ - return dist_10000(generator); -} - -static void BenchmarkVectorOperations(benchmark::State& state) { - for(auto _ : state) - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000() / 10), "read"}; -} - -BENCHMARK(BenchmarkVectorOperations); - -static void BenchmarkHasPolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for (int i = 0; i < 100; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for (auto _ : state) - params = { "user" + std::to_string(GetRandom100()), "data" + std::to_string(GetRandom100()/10), "read" }, e.HasPolicy(params); -} - -BENCHMARK(BenchmarkHasPolicySmall); - -static void BenchmarkAddPolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for(int i = 0; i < 100; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i/10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = {"user" + std::to_string(GetRandom100() + 100), "data" + std::to_string((GetRandom100() + 100)/10), "read"}, e.AddPolicy(params); -} - -BENCHMARK(BenchmarkAddPolicySmall); - -static void BenchmarkRemovePolicySmall(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 100 roles, 10 resources. - for(int i = 100; i < 100; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom100()), "data" + std::to_string(GetRandom100() / 10), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicySmall); diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224234.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224234.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224322.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224322.cpp deleted file mode 100644 index 544d1c33..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224322.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224328.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224328.cpp deleted file mode 100644 index 8befc832..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224328.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224341.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224341.cpp deleted file mode 100644 index 11238e69..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224341.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -// BENCHMARK(BenchmarkHasPolicyMedium); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224350.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224350.cpp deleted file mode 100644 index 4cf3a4fa..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224350.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -// BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -// BENCHMARK(BenchmarkHasPolicyLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224401.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224401.cpp deleted file mode 100644 index 798750e7..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224401.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -// BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -// BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyMedium); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224409.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224409.cpp deleted file mode 100644 index f4584892..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224409.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -// BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -// BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyMedium); - -static void BenchmarkAddPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i/10), "read" }, e.AddPolicy(params); - - for(auto _ : state) { - params = { "user" + std::to_string(GetRandom10000() + 10000), "data" + std::to_string((GetRandom10000() + 10000) / 10), "read" }, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224420.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224420.cpp deleted file mode 100644 index 492e8c69..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224420.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -// BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -// BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyMedium); - -static void BenchmarkAddPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i/10), "read" }, e.AddPolicy(params); - - for(auto _ : state) { - params = { "user" + std::to_string(GetRandom10000() + 10000), "data" + std::to_string((GetRandom10000() + 10000) / 10), "read" }, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyLarge); - -static void BenchmarkRemovePolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000() / 10), "read" }, e.RemovePolicy(params); -} - -// BENCHMARK(BenchmarkRemovePolicyMedium); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224429.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224429.cpp deleted file mode 100644 index 0e860bae..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224429.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -// BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -// BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyMedium); - -static void BenchmarkAddPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i/10), "read" }, e.AddPolicy(params); - - for(auto _ : state) { - params = { "user" + std::to_string(GetRandom10000() + 10000), "data" + std::to_string((GetRandom10000() + 10000) / 10), "read" }, e.AddPolicy(params); - } -} - -// BENCHMARK(BenchmarkAddPolicyLarge); - -static void BenchmarkRemovePolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000() / 10), "read" }, e.RemovePolicy(params); -} - -// BENCHMARK(BenchmarkRemovePolicyMedium); - -static void BenchmarkRemovePolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom1000()), "read" }, e.RemovePolicy(params); -} - -// BENCHMARK(BenchmarkRemovePolicyLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224447.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224447.cpp deleted file mode 100644 index 3df21b75..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224447.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -BENCHMARK(BenchmarkAddPolicyMedium); - -static void BenchmarkAddPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i/10), "read" }, e.AddPolicy(params); - - for(auto _ : state) { - params = { "user" + std::to_string(GetRandom10000() + 10000), "data" + std::to_string((GetRandom10000() + 10000) / 10), "read" }, e.AddPolicy(params); - } -} - -BENCHMARK(BenchmarkAddPolicyLarge); - -static void BenchmarkRemovePolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000() / 10), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicyMedium); - -static void BenchmarkRemovePolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom1000()), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicyLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102224715.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102224715.cpp deleted file mode 100644 index c002d226..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102224715.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -BENCHMARK(BenchmarkAddPolicyMedium); - -static void BenchmarkAddPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i/10), "read" }, e.AddPolicy(params); - - for(auto _ : state) { - params = { "user" + std::to_string(GetRandom10000() + 10000), "data" + std::to_string((GetRandom10000() + 10000) / 10), "read" }, e.AddPolicy(params); - } -} - -BENCHMARK(BenchmarkAddPolicyLarge); - -static void BenchmarkRemovePolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000() / 10), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicyMedium); - -static void BenchmarkRemovePolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom1000()), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicyLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/management_api_b_inten_20211102231212.cpp b/.history/tests/benchmarks/management_api_b_inten_20211102231212.cpp deleted file mode 100644 index 189b0ceb..00000000 --- a/.history/tests/benchmarks/management_api_b_inten_20211102231212.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin's Management API -*/ - -#include -#include -#include -#include "config_path.h" - -static std::random_device generator; -static std::uniform_int_distribution dist_100(1, 100); -static std::uniform_int_distribution dist_1000(1, 1000); -static std::uniform_int_distribution dist_10000(1, 10000); -static std::vector params(3); - -static inline int GetRandom100() -{ - return dist_100(generator); -} - -static inline int GetRandom1000() -{ - return dist_1000(generator); -} - -static inline int GetRandom10000() -{ - return dist_10000(generator); -} - -static void BenchmarkHasPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - // std::vector> p_policies(1000); - for (int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // e.AddPolicies(p_policies); - for (auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000()/10), "read" }, e.HasPolicy(params); -} - -BENCHMARK(BenchmarkHasPolicyMedium); - -static void BenchmarkHasPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for (int i = 0; i < 10000; i++) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom10000()/10), "read"}, e.HasPolicy(params); - } -} - -BENCHMARK(BenchmarkHasPolicyLarge); - -static void BenchmarkAddPolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - // _, err := e.AddPolicies(pPolicies) - - for(auto _ : state) { - params = {"user" + std::to_string(GetRandom1000() + 1000), "data" + std::to_string((GetRandom1000() + 1000) / 10), "read"}, e.AddPolicy(params); - } -} - -BENCHMARK(BenchmarkAddPolicyMedium); - -static void BenchmarkAddPolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i/10), "read" }, e.AddPolicy(params); - - for(auto _ : state) { - params = { "user" + std::to_string(GetRandom10000() + 10000), "data" + std::to_string((GetRandom10000() + 10000) / 10), "read" }, e.AddPolicy(params); - } -} - -BENCHMARK(BenchmarkAddPolicyLarge); - -static void BenchmarkRemovePolicyMedium(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 1000 roles, 100 resources. - for(int i = 0; i < 1000; ++i) - params = {"user" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom1000()), "data" + std::to_string(GetRandom1000() / 10), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicyMedium); - -static void BenchmarkRemovePolicyLarge(benchmark::State& state) { - casbin::Enforcer e(basic_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - params = { "user" + std::to_string(i), "data" + std::to_string(i / 10), "read" }, e.AddPolicy(params); - - for(auto _ : state) - params = { "user" + std::to_string(GetRandom10000()), "data" + std::to_string(GetRandom1000()), "read" }, e.RemovePolicy(params); -} - -BENCHMARK(BenchmarkRemovePolicyLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/model_b_20211101202915.cpp b/.history/tests/benchmarks/model_b_20211101202915.cpp deleted file mode 100644 index 1798bb8a..00000000 --- a/.history/tests/benchmarks/model_b_20211101202915.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin::Model -*/ - -#include -#include -#include "config_path.h" - -static const std::vector> s_policy = { {"alice", "data1", "read"}, {"bob", "data2", "write"} }; - -static bool rawEnforce(const std::string& sub, const std::string& obj, const std::string& act) { - for(const auto& rule : s_policy) { - if(rule[0] == sub && rule[1] == obj && rule[2] == act) - return true; - } - return false; -} - -static void BenchmarkRaw(benchmark::State& state) { - for(auto _ : state) - rawEnforce("alice", "data1", "read"); -} - -BENCHMARK(BenchmarkRaw); - -static void BenchmarkBasicModel(benchmark::State& state) { - casbin::Enforcer e(basic_model_path, basic_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkBasicModel); - -static void BenchmarkRBACModel(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path, rbac_policy_path); - - casbin::DataList params = {"alice", "data2", "read"}; - - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModel); - -static void BenchmarkRBACModelSmall(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 100 roles, 10 resources. - for(int i = 0; i < 100; ++i) - e.AddPolicy({ "group" + std::to_string(i), "data" + std::to_string(i/10), "read" }); - - // 1000 users. - for(int i = 0; i < 1000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i / 10) }); - - casbin::DataList params = {"user501", "data9", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelSmall); - -static void BenchmarkRBACModelMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 10000 users. - for (int i = 0; i < 10000; ++i) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user5001", "data99", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -// BENCHMARK(BenchmarkRBACModelMedium); - -static void BenchmarkRBACModelLarge(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 100000 users. - for(int i = 0; i < 100000; i++) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user50001", "data999", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -// BENCHMARK(BenchmarkRBACModelLarge); - -static void BenchmarkRBACModelWithResourceRoles(benchmark::State& state) { - casbin::Enforcer e(rbac_with_resource_roles_model_path, rbac_with_resource_roles_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelWithResourceRoles); - -static void BenchmarkRBACModelWithDomains(benchmark::State& state) { - casbin::Enforcer e(rbac_with_domains_model_path, rbac_with_domains_policy_path); - casbin::DataList params = {"alice", "domain1", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelWithDomains); - -// ------ TODO ------ -// static void BenchmarkABACModel(benchmark::State& state) { -// casbin::Enforcer e("examples/abac_model.conf") -// data1 := newTestResource("data1", "alice") - - -// for(auto _ : state) { -// _, _ = e.Enforce("alice", data1, "read") -// } -// } - -static void BenchmarkKeyMatchModel(benchmark::State& state) { - casbin::Enforcer e(keymatch_model_path, keymatch_policy_path); - casbin::DataList params = {"alice", "/alice_data/resource1", "GET"}; - - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkKeyMatchModel); - -static void BenchmarkRBACModelWithDeny(benchmark::State& state) { - casbin::Enforcer e(rbac_with_deny_model_path, rbac_with_deny_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelWithDeny); - -static void BenchmarkPriorityModel(benchmark::State& state) { - casbin::Enforcer e(priority_model_path, priority_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkPriorityModel); diff --git a/.history/tests/benchmarks/model_b_20211102234252.cpp b/.history/tests/benchmarks/model_b_20211102234252.cpp deleted file mode 100644 index 43684321..00000000 --- a/.history/tests/benchmarks/model_b_20211102234252.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin::Model -*/ - -#include -#include -#include "config_path.h" - -static const std::vector> s_policy = { {"alice", "data1", "read"}, {"bob", "data2", "write"} }; - -static bool rawEnforce(const std::string& sub, const std::string& obj, const std::string& act) { - for(const auto& rule : s_policy) { - if(rule[0] == sub && rule[1] == obj && rule[2] == act) - return true; - } - return false; -} - -static void BenchmarkRaw(benchmark::State& state) { - for(auto _ : state) - rawEnforce("alice", "data1", "read"); -} - -BENCHMARK(BenchmarkRaw); - -static void BenchmarkBasicModel(benchmark::State& state) { - casbin::Enforcer e(basic_model_path, basic_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkBasicModel); - -static void BenchmarkRBACModel(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path, rbac_policy_path); - - casbin::DataList params = {"alice", "data2", "read"}; - - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModel); - -static void BenchmarkRBACModelSmall(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 100 roles, 10 resources. - for(int i = 0; i < 100; ++i) - e.AddPolicy({ "group" + std::to_string(i), "data" + std::to_string(i/10), "read" }); - - // 1000 users. - for(int i = 0; i < 1000; ++i) - e.AddGroupingPolicy({ "user" + std::to_string(i), "group" + std::to_string(i / 10) }); - - casbin::DataList params = {"user501", "data9", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelSmall); - -static void BenchmarkRBACModelWithResourceRoles(benchmark::State& state) { - casbin::Enforcer e(rbac_with_resource_roles_model_path, rbac_with_resource_roles_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelWithResourceRoles); - -static void BenchmarkRBACModelWithDomains(benchmark::State& state) { - casbin::Enforcer e(rbac_with_domains_model_path, rbac_with_domains_policy_path); - casbin::DataList params = {"alice", "domain1", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelWithDomains); - -// ------ TODO ------ -// static void BenchmarkABACModel(benchmark::State& state) { -// casbin::Enforcer e("examples/abac_model.conf") -// data1 := newTestResource("data1", "alice") - - -// for(auto _ : state) { -// _, _ = e.Enforce("alice", data1, "read") -// } -// } - -static void BenchmarkKeyMatchModel(benchmark::State& state) { - casbin::Enforcer e(keymatch_model_path, keymatch_policy_path); - casbin::DataList params = {"alice", "/alice_data/resource1", "GET"}; - - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkKeyMatchModel); - -static void BenchmarkRBACModelWithDeny(benchmark::State& state) { - casbin::Enforcer e(rbac_with_deny_model_path, rbac_with_deny_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelWithDeny); - -static void BenchmarkPriorityModel(benchmark::State& state) { - casbin::Enforcer e(priority_model_path, priority_policy_path); - casbin::DataList params = {"alice", "data1", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkPriorityModel); diff --git a/.history/tests/benchmarks/model_b_inten_20211102224501.cpp b/.history/tests/benchmarks/model_b_inten_20211102224501.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/.history/tests/benchmarks/model_b_inten_20211102224520.cpp b/.history/tests/benchmarks/model_b_inten_20211102224520.cpp deleted file mode 100644 index 524d9387..00000000 --- a/.history/tests/benchmarks/model_b_inten_20211102224520.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::Model -*/ - -#include -#include -#include "config_path.h" - -static const std::vector> s_policy = { {"alice", "data1", "read"}, {"bob", "data2", "write"} }; \ No newline at end of file diff --git a/.history/tests/benchmarks/model_b_inten_20211102224600.cpp b/.history/tests/benchmarks/model_b_inten_20211102224600.cpp deleted file mode 100644 index 465827cc..00000000 --- a/.history/tests/benchmarks/model_b_inten_20211102224600.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::Model -*/ - -#include -#include -#include "config_path.h" - -static const std::vector> s_policy = { {"alice", "data1", "read"}, {"bob", "data2", "write"} }; -static void BenchmarkRBACModelMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 10000 users. - for (int i = 0; i < 10000; ++i) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user5001", "data99", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -// BENCHMARK(BenchmarkRBACModelMedium); \ No newline at end of file diff --git a/.history/tests/benchmarks/model_b_inten_20211102224609.cpp b/.history/tests/benchmarks/model_b_inten_20211102224609.cpp deleted file mode 100644 index 2d0d42dc..00000000 --- a/.history/tests/benchmarks/model_b_inten_20211102224609.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::Model -*/ - -#include -#include -#include "config_path.h" - -static const std::vector> s_policy = { {"alice", "data1", "read"}, {"bob", "data2", "write"} }; -static void BenchmarkRBACModelMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 10000 users. - for (int i = 0; i < 10000; ++i) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user5001", "data99", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -// BENCHMARK(BenchmarkRBACModelMedium); - -static void BenchmarkRBACModelLarge(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 100000 users. - for(int i = 0; i < 100000; i++) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user50001", "data999", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -// BENCHMARK(BenchmarkRBACModelLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/model_b_inten_20211102224625.cpp b/.history/tests/benchmarks/model_b_inten_20211102224625.cpp deleted file mode 100644 index ba02fe27..00000000 --- a/.history/tests/benchmarks/model_b_inten_20211102224625.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::Model -*/ - -#include -#include -#include "config_path.h" - -static const std::vector> s_policy = { {"alice", "data1", "read"}, {"bob", "data2", "write"} }; -static void BenchmarkRBACModelMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 10000 users. - for (int i = 0; i < 10000; ++i) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user5001", "data99", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelMedium); - -static void BenchmarkRBACModelLarge(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 100000 users. - for(int i = 0; i < 100000; i++) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user50001", "data999", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/model_b_inten_20211102224711.cpp b/.history/tests/benchmarks/model_b_inten_20211102224711.cpp deleted file mode 100644 index 733b3075..00000000 --- a/.history/tests/benchmarks/model_b_inten_20211102224711.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::Model -*/ - -#include -#include -#include "config_path.h" - -static const std::vector> s_policy = { {"alice", "data1", "read"}, {"bob", "data2", "write"} }; -static void BenchmarkRBACModelMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 1000 roles, 100 resources. - for (int i = 0; i < 1000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 10000 users. - for (int i = 0; i < 10000; ++i) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user5001", "data99", "read"}; - for (auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelMedium); - -static void BenchmarkRBACModelLarge(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 10000 roles, 1000 resources. - for(int i = 0; i < 10000; ++i) - e.AddPolicy({"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}); - - // 100000 users. - for(int i = 0; i < 100000; i++) - e.AddGroupingPolicy({"user" + std::to_string(i), "group" + std::to_string(i / 10)}); - - casbin::DataList params = {"user50001", "data999", "read"}; - - for(auto _ : state) - e.Enforce(params); -} - -BENCHMARK(BenchmarkRBACModelLarge); \ No newline at end of file diff --git a/.history/tests/benchmarks/role_manager_b_20211101202748.cpp b/.history/tests/benchmarks/role_manager_b_20211101202748.cpp deleted file mode 100644 index 03333ec7..00000000 --- a/.history/tests/benchmarks/role_manager_b_20211101202748.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin::RoleManager -*/ - -#include -#include -#include "config_path.h" - -static std::vector params(3); -static std::vector g_params(2); - -static void BenchmarkRoleManagerSmall(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - // Do not rebuild the role inheritance relations for every AddGroupingPolicy() call. - e.EnableAutoBuildRoleLinks(false); - - // 100 roles, 10 resources. - for (int i = 0; i < 100; ++i) - params = {"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - // 1000 users. - for (int i = 0; i < 1000; ++i) - g_params = {"user" + std::to_string(i), "group" + std::to_string(i / 10)}, e.AddGroupingPolicy(g_params); - - auto rm = e.GetRoleManager(); - - for(auto _ : state) { - for(int j = 0; j < 100; ++j) - rm->HasLink("user501", "group" + std::to_string(j)); - } -} - -BENCHMARK(BenchmarkRoleManagerSmall); - -static void BenchmarkRoleManagerMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - // Do not rebuild the role inheritance relations for every AddGroupingPolicy() call. - e.EnableAutoBuildRoleLinks(false); - - // 1000 roles, 100 resources. - - for (int i = 0; i < 1000; ++i) - params = {"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - // 10000 users. - - for (int i = 0; i < 10000; ++i) - g_params = {"user" + std::to_string(i), "group" + std::to_string(i / 10)}, e.AddGroupingPolicy(g_params); - - e.BuildRoleLinks(); - - auto rm = e.GetRoleManager(); - - for(auto _ : state) { - for(int j = 0; j < 1000; ++j) - rm->HasLink("user501", "group" + std::to_string(j)); - } -} - -// BENCHMARK(BenchmarkRoleManagerMedium); - -static void BenchmarkRoleManagerLarge(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 10000 roles, 1000 resources. - - for (int i = 0; i < 10000; ++i) - params = {"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - // 100000 users. - - for (int i = 0; i < 100000; ++i) - g_params = {"user" + std::to_string(i), "group" + std::to_string(i / 10)}, e.AddGroupingPolicy(g_params); - - auto rm = e.GetRoleManager(); - - for(auto _ : state) { - for(int j = 0; j < 10000; ++j) - rm->HasLink("user501", "group" + std::to_string(j)); - } -} - -// BENCHMARK(BenchmarkRoleManagerLarge); diff --git a/.history/tests/benchmarks/role_manager_b_20211102234307.cpp b/.history/tests/benchmarks/role_manager_b_20211102234307.cpp deleted file mode 100644 index f6dc4d45..00000000 --- a/.history/tests/benchmarks/role_manager_b_20211102234307.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a test file for benchmarking the performance of casbin::RoleManager -*/ - -#include -#include -#include "config_path.h" - -static std::vector params(3); -static std::vector g_params(2); - -static void BenchmarkRoleManagerSmall(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - // Do not rebuild the role inheritance relations for every AddGroupingPolicy() call. - e.EnableAutoBuildRoleLinks(false); - - // 100 roles, 10 resources. - for (int i = 0; i < 100; ++i) - params = {"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - // 1000 users. - for (int i = 0; i < 1000; ++i) - g_params = {"user" + std::to_string(i), "group" + std::to_string(i / 10)}, e.AddGroupingPolicy(g_params); - - auto rm = e.GetRoleManager(); - - for(auto _ : state) { - for(int j = 0; j < 100; ++j) - rm->HasLink("user501", "group" + std::to_string(j)); - } -} - -BENCHMARK(BenchmarkRoleManagerSmall); diff --git a/.history/tests/benchmarks/role_manager_b_inten_20211102224636.cpp b/.history/tests/benchmarks/role_manager_b_inten_20211102224636.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/.history/tests/benchmarks/role_manager_b_inten_20211102224651.cpp b/.history/tests/benchmarks/role_manager_b_inten_20211102224651.cpp deleted file mode 100644 index e5adb818..00000000 --- a/.history/tests/benchmarks/role_manager_b_inten_20211102224651.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is a intensive test file for benchmarking the performance of casbin::RoleManager -*/ - -#include -#include -#include "config_path.h" - -static std::vector params(3); -static std::vector g_params(2); \ No newline at end of file diff --git a/.history/tests/benchmarks/role_manager_b_inten_20211102224653.cpp b/.history/tests/benchmarks/role_manager_b_inten_20211102224653.cpp deleted file mode 100644 index efad97ed..00000000 --- a/.history/tests/benchmarks/role_manager_b_inten_20211102224653.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::RoleManager -*/ - -#include -#include -#include "config_path.h" - -static std::vector params(3); -static std::vector g_params(2); \ No newline at end of file diff --git a/.history/tests/benchmarks/role_manager_b_inten_20211102224707.cpp b/.history/tests/benchmarks/role_manager_b_inten_20211102224707.cpp deleted file mode 100644 index efad97ed..00000000 --- a/.history/tests/benchmarks/role_manager_b_inten_20211102224707.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::RoleManager -*/ - -#include -#include -#include "config_path.h" - -static std::vector params(3); -static std::vector g_params(2); \ No newline at end of file diff --git a/.history/tests/benchmarks/role_manager_b_inten_20211102224739.cpp b/.history/tests/benchmarks/role_manager_b_inten_20211102224739.cpp deleted file mode 100644 index 2d9d1319..00000000 --- a/.history/tests/benchmarks/role_manager_b_inten_20211102224739.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::RoleManager -*/ - -#include -#include -#include "config_path.h" - -static std::vector params(3); -static std::vector g_params(2); - -static void BenchmarkRoleManagerMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - // Do not rebuild the role inheritance relations for every AddGroupingPolicy() call. - e.EnableAutoBuildRoleLinks(false); - - // 1000 roles, 100 resources. - - for (int i = 0; i < 1000; ++i) - params = {"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - // 10000 users. - - for (int i = 0; i < 10000; ++i) - g_params = {"user" + std::to_string(i), "group" + std::to_string(i / 10)}, e.AddGroupingPolicy(g_params); - - e.BuildRoleLinks(); - - auto rm = e.GetRoleManager(); - - for(auto _ : state) { - for(int j = 0; j < 1000; ++j) - rm->HasLink("user501", "group" + std::to_string(j)); - } -} - -BENCHMARK(BenchmarkRoleManagerMedium); \ No newline at end of file diff --git a/.history/tests/benchmarks/role_manager_b_inten_20211102224750.cpp b/.history/tests/benchmarks/role_manager_b_inten_20211102224750.cpp deleted file mode 100644 index 6529e411..00000000 --- a/.history/tests/benchmarks/role_manager_b_inten_20211102224750.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright 2021 The casbin Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This is an intensive test file for benchmarking the performance of casbin::RoleManager -*/ - -#include -#include -#include "config_path.h" - -static std::vector params(3); -static std::vector g_params(2); - -static void BenchmarkRoleManagerMedium(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - // Do not rebuild the role inheritance relations for every AddGroupingPolicy() call. - e.EnableAutoBuildRoleLinks(false); - - // 1000 roles, 100 resources. - - for (int i = 0; i < 1000; ++i) - params = {"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - // 10000 users. - - for (int i = 0; i < 10000; ++i) - g_params = {"user" + std::to_string(i), "group" + std::to_string(i / 10)}, e.AddGroupingPolicy(g_params); - - e.BuildRoleLinks(); - - auto rm = e.GetRoleManager(); - - for(auto _ : state) { - for(int j = 0; j < 1000; ++j) - rm->HasLink("user501", "group" + std::to_string(j)); - } -} - -BENCHMARK(BenchmarkRoleManagerMedium); - -static void BenchmarkRoleManagerLarge(benchmark::State& state) { - casbin::Enforcer e(rbac_model_path); - - // 10000 roles, 1000 resources. - - for (int i = 0; i < 10000; ++i) - params = {"group" + std::to_string(i), "data" + std::to_string(i / 10), "read"}, e.AddPolicy(params); - - // 100000 users. - - for (int i = 0; i < 100000; ++i) - g_params = {"user" + std::to_string(i), "group" + std::to_string(i / 10)}, e.AddGroupingPolicy(g_params); - - auto rm = e.GetRoleManager(); - - for(auto _ : state) { - for(int j = 0; j < 10000; ++j) - rm->HasLink("user501", "group" + std::to_string(j)); - } -} - -BENCHMARK(BenchmarkRoleManagerLarge); \ No newline at end of file