casbin4d/Casbin4D

performance is lower than expected

cybexr opened this issue · 9 comments

Intresting project, but why Pascal version is slower than Golang, it doesn't make sense.

Golang: RBAC (small) | 1100 rules (1000 users, 100 roles) | 0.164309 ms/op
Delphi: RBAC (Small) | 1,100 Rules (1,000 Users, 100 roles) | 238.945 ms/op

jkour commented

Hi @cybexr,

I don't know Go so I am not able to say why there is this difference. I do not know how the timer works in Go but in Delphi Windows timer is not very accurate.

Perhaps the results are different if a high precision timer is used. Additionally, this time measurement depends a lot on the background processes in a system.

Have you tried to run the benchmarks on your PC? It would be interesting to see how these tests score on another machine.

the above result comes from officail document.
Below is my Carsbin4D test on my PC ( E3-1285Lv3 3.1Ghz)

RBAC Model Small [1100 Rules (1000 Users, 100 Role)]: 100 operations in 4.340964 sec (0.043410 sec/op) using 352 bytes (352 bytes) of memory

Please run Go and Delphi in the same machine.

@hsluoyz Is there some casbin benchmark pre-build win32 exe ?

@hsluoyz Seems casbin uses govaluate (https://github.com/Knetic/govaluate) library to parse match-expression, and casbin4D uses what?

No. Please install Go by yourself. It's not hard.

jkour commented

casbin4D uses TExpressionParser

This is an old project which I have in my plans to refactor (but never had the time :-)). Of course, pull requests are always welcome.

Your results are better than those I got.

On an general note, I wouldn't use benchmarks as a definitive guide as they run in a very controlled environment; something that you do not really find in production sites.

For example, you wouldn't really load 1,000 users and 100 roles in memory. Probably, you would have a file or a databases and you would run queries to load the data. So, my point is that this delay may mean little in practice.

Of course, if you have 1,000,000 users then every little msec counts.