hyperjumptech / grule-rule-engine

Rule engine implementation in Golang
Other
2.21k stars 343 forks source link

[Info]: After the shortcircuit evaluation the benchmarks looks even better #129

Closed jinagamvasubabu closed 4 years ago

jinagamvasubabu commented 4 years ago

@newm4n Just want to highlight after short-circuit changes, benchmarks are looking even better, please find the detailed report below

Before ShortCircuit Changes:

goos: darwin goarch: amd64 pkg: github.com/hyperjumptech/grule-rule-engine/examples/benchmark


Benchmark_Grule_Execution_Engine/100_rules-12              35340             33921 ns/op            4391 B/op         78 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#01-12           29650             34346 ns/op            4446 B/op         79 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#02-12           29587             34380 ns/op            4429 B/op         79 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#03-12           31029             34342 ns/op            4423 B/op         78 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#04-12           29646             35943 ns/op            4451 B/op         79 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#05-12           35835             33039 ns/op            4402 B/op         78 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#06-12           29305             34495 ns/op            4390 B/op         79 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#07-12           28704             34857 ns/op            4397 B/op         79 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#08-12           34936             34349 ns/op            4448 B/op         78 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#09-12           36352             33935 ns/op            4332 B/op         77 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#10-12           30698             39917 ns/op            4377 B/op         79 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules-12              3478            317176 ns/op           43912 B/op        690 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#01-12           3434            319312 ns/op           44239 B/op        698 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#02-12           3565            321366 ns/op           43288 B/op        675 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#03-12           3385            330214 ns/op           44611 B/op        707 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#04-12           2544            454601 ns/op           53267 B/op        916 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#05-12            744           1420603 ns/op          137563 B/op       2953 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#06-12           1472            824068 ns/op           78644 B/op       1529 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#07-12           2671            408376 ns/op           51611 B/op        876 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#08-12           3524            359907 ns/op           43579 B/op        682 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#09-12           2970            357360 ns/op           48268 B/op        795 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#10-12           3511            367940 ns/op           43670 B/op        684 allocs/op

Benchmark_Grule_Load_Rules/100_rules-12                       44          23445211 ns/op         8871465 B/op     216553 allocs/op
Benchmark_Grule_Load_Rules/100_rules#01-12                    51          24634072 ns/op         8871551 B/op     216554 allocs/op
Benchmark_Grule_Load_Rules/100_rules#02-12                    46          25222948 ns/op         8871361 B/op     216553 allocs/op
Benchmark_Grule_Load_Rules/100_rules#03-12                    44          28146387 ns/op         8871486 B/op     216553 allocs/op
Benchmark_Grule_Load_Rules/100_rules#04-12                    45          30634115 ns/op         8871631 B/op     216554 allocs/op
Benchmark_Grule_Load_Rules/100_rules#05-12                    49          22554323 ns/op         8871228 B/op     216552 allocs/op
Benchmark_Grule_Load_Rules/100_rules#06-12                    46          22489783 ns/op         8871493 B/op     216554 allocs/op
Benchmark_Grule_Load_Rules/100_rules#07-12                    54          25210478 ns/op         8871489 B/op     216554 allocs/op
Benchmark_Grule_Load_Rules/100_rules#08-12                    54          23163462 ns/op         8871450 B/op     216553 allocs/op
Benchmark_Grule_Load_Rules/100_rules#09-12                    51          37621286 ns/op         8871515 B/op     216554 allocs/op
Benchmark_Grule_Load_Rules/100_rules#10-12                    33          37549279 ns/op         8871417 B/op     216553 allocs/op
Benchmark_Grule_Load_Rules/1000_rules-12                       4         345123608 ns/op        88642916 B/op    2141300 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#01-12                    3         358250329 ns/op        88638602 B/op    2141279 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#02-12                    3         347296778 ns/op        88646288 B/op    2141318 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#03-12                    5         283385379 ns/op        88643715 B/op    2141304 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#04-12                    3         372053420 ns/op        88643888 B/op    2141303 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#05-12                    5         213746759 ns/op        88643011 B/op    2141299 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#06-12                    6         230968014 ns/op        88641652 B/op    2141293 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#07-12                    5         216604105 ns/op        88645020 B/op    2141310 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#08-12                    5         213267279 ns/op        88640585 B/op    2141289 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#09-12                    5         214347871 ns/op        88641289 B/op    2141292 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#10-12                    5         211954473 ns/op        88642294 B/op    2141297 allocs/op

After ShortCircuit Changes:

XXXXX@Vasu-Macbook ~/g/s/g/e/benchmark> go test -bench=. -benchmem
goos: darwin
goarch: amd64
pkg: github.com/hyperjumptech/grule-rule-engine/examples/benchmark
Benchmark_Grule_Execution_Engine/100_rules-12            2055945               574 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#01-12         2048078               570 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#02-12         2086953               572 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#03-12         2094231               571 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#04-12         2078065               576 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#05-12         2028356               642 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#06-12         2002248               628 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#07-12         1850121               703 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#08-12         1761343               585 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#09-12         2080953               594 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/100_rules#10-12         2082880               573 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules-12           2082183               575 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#01-12        2098585               568 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#02-12        2090640               570 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#03-12        2109938               587 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#04-12        2045216               576 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#05-12        2092534               575 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#06-12        1994415               579 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#07-12        2098788               599 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#08-12        2092808               573 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#09-12        2085716               609 ns/op             512 B/op          9 allocs/op
Benchmark_Grule_Execution_Engine/1000_rules#10-12        1864302               576 ns/op             512 B/op          9 allocs/op

Benchmark_Grule_Load_Rules/100_rules-12                    67137             17387 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#01-12                 67485             17447 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#02-12                 67332             17408 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#03-12                 67992             17436 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#04-12                 68170             17420 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#05-12                 67777             17645 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#06-12                 65100             17431 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#07-12                 67396             17396 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#08-12                 68132             17458 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#09-12                 67881             17399 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/100_rules#10-12                 67216             17523 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules-12                   66828             17823 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#01-12                69122             17581 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#02-12                67815             17425 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#03-12                67405             19681 ns/op            5070 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#04-12                48511             21222 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#05-12                67779             18999 ns/op            5070 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#06-12                56694             17691 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#07-12                69086             17641 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#08-12                51638             19401 ns/op            5070 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#09-12                58940             20498 ns/op            5071 B/op        118 allocs/op
Benchmark_Grule_Load_Rules/1000_rules#10-12                67411             19487 ns/op            5071 B/op        118 allocs/op
jinagamvasubabu commented 4 years ago

We will update the benchmark results and raise a PR for the same

newm4n commented 4 years ago

Wow !. Thanks a lot man.

jinagamvasubabu commented 4 years ago

PR has been raised