Skip to content

Commit

Permalink
feat: [basic_model_speedup] new fare benchmark for large basic model
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyChashchegorov committed Mar 5, 2024
1 parent bffafea commit 59828e4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/benchmarks/model_b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ static void BenchmarkBasicModel(benchmark::State& state) {

BENCHMARK(BenchmarkBasicModel);

static void BenchmarkBasicModelLargeSize(benchmark::State& state) {
casbin::Enforcer e(rbac_model_path, "", false);

size_t actors_count = 10;
size_t resources_count = 100;
size_t resource_actor_rate = resources_count / actors_count;
size_t actions_count = 5;

for (size_t j = 0; j < resources_count; ++j)
for (size_t k = 0; k < actions_count; ++k)
e.AddPolicy({
"actor" + std::to_string(j % resource_actor_rate),
"resource" + std::to_string(j),
"action" + std::to_string(k)
});

casbin::DataList params = {
"actor" + std::to_string(actors_count - 1),
"resource" + std::to_string(resources_count - 1),
"action" + std::to_string(actions_count - 1)
};
for (auto _ : state) e.Enforce(params);
}

BENCHMARK(BenchmarkBasicModelLargeSize);

static void BenchmarkRBACModel(benchmark::State& state) {
casbin::Enforcer e(rbac_model_path, rbac_policy_path, false);

Expand Down

0 comments on commit 59828e4

Please sign in to comment.