After watching a Netflix documentary about Benford’s Law, i got really interested in it because it can help detect fraud in e.g. balance sheets. So i searched my favorite programming languages and detected that there is no npm Package for checking Benford’s Law.
But i think this gives us a good example of a algorithm which is implemented in different programming languages and can be benchmarked. That’s what i wanna do in this post: Comparing the Benford’s Law check in different Languages.
Testing the Performance⌗
Repo with Source Code: https://github.com/CMiksche/benford-benchmark
|Language & Version||GitHub Repo of Library||Performance|
|Python 3.8.5||huntlib||1,86 secs|
|Crystal 0.35.1||benfordslaw.cr||14,20 millis|
|Go 1.15||benford||7,03 millis|
|JS (node) v14.8.0||benfordslaw||164,71 millis|
I didn’t expected that big difference. Go is clearly the winner here and that with big distance to the other implementations. One reason why Python took so long may be that the used library shows additional information but i don’t think Python could compete with the other implementations if the library wouldn’t show more.
It is also noteworthy that Go is very very fast compiling. Crystal isn’t even in the area of the Go compile time.