A reproducible benchmark of two business rules engines evaluating the same rule against the same 100,000 orders:
- Code Effects 7, a .NET rules engine that compiles rules to .NET code and evaluates the application's own objects
- GoRules ZEN Engine 2.1, a rules engine written in Rust, called both through its official .NET binding and natively from Rust
Result, one thread, per evaluation: in a .NET application, Code Effects evaluated the rule in 0.31 µs; the GoRules ZEN Engine took about 50 µs through its .NET binding, and 0.88 µs in its best native Rust case (the bare expression, with input already converted to its own value type).
Both engines gave the same answer for every one of the 100,000 orders before any timing was recorded.
The full write-up: Code Effects vs Rust Rules Engines: What a Rust Engine Costs a .NET Application.
Total is greater than 500, and Country is US or CA, and at least one order line has Quantity of 10 or more and Price over 20, and Tags contains "priority"
| Engine | Form | File |
|---|---|---|
| Code Effects | Rule XML, with the line condition as an item rule | CeVsZen/Rules/order-rule.xml |
| GoRules | JSON Decision Model: input, one expression node, output | CeVsZen/Rules/order-decision.json |
The GoRules expression:
total > 500 and country in ['US', 'CA'] and some(lines, #.quantity >= 10 and #.price > 20) and contains(tags, 'priority')
The source object (CeVsZen/Order.cs) is a plain class with one reference collection (Lines) and one value collection (Tags).
100,000 distinct orders generated from a fixed seed (42), identical on every run: 1 to 20 lines and 0 to 5 tags per order, 27.5% matching the rule. Each order is evaluated once per pass. A single order evaluated 100,000 times would favor whichever engine caches more.
Windows 11, Intel Core Ultra 7 155H (16 cores, 22 threads), .NET 8.0.34, Rust release build with full link-time optimization. Raw output is in results/.
| Time per evaluation | vs Code Effects | Allocated | |
|---|---|---|---|
| Code Effects, .NET, live objects | 0.31 µs | 1× | 118 B |
| GoRules, native Rust, bare expression, input already in its value type | 0.88 µs | 2.9× | n/a |
| GoRules, native Rust, decision, input already in its value type | 5.1 µs | 17× | n/a |
| GoRules, .NET binding, bare expression, input already JSON | 9.3 µs | 30× | 808 B |
| GoRules, native Rust, decision, parsing JSON each call | 12.7 µs | 41× | n/a |
| GoRules, .NET binding, decision, input already JSON | 49.9 µs | 161× | 1,805 B |
| GoRules, .NET binding, decision, serializing each order | 53.9 µs | 174× | 2,736 B |
The GoRules .NET binding's EvaluateBatch runs each request on its own worker thread inside the Rust library. It is therefore compared with Code Effects running across all cores (Parallel.For), not with single-threaded Code Effects.
| Time per evaluation | vs Code Effects | |
|---|---|---|
Code Effects, .NET, live objects, Parallel.For |
0.041 µs | 1× |
GoRules, .NET binding, EvaluateBatch, input already JSON |
4.2 µs | 103× |
GoRules, .NET binding, EvaluateBatch, serializing each order |
6.7 µs | 165× |
Measured separately on the same data:
| Step | Time |
|---|---|
| .NET serializing one order to JSON (System.Text.Json) | 2.0 µs |
| Rust parsing one order's JSON into the engine's value type | 7.9 µs |
Approximate breakdown of a GoRules decision called from .NET, derived by subtracting the measured cases (not measured directly):
| Approx. time | |
|---|---|
| Serialization in .NET | ~2 µs |
| Parsing into the engine's value type | ~8 µs |
| Evaluating the decision | ~5 µs |
| The binding's per-call overhead (async call and hand-off to a worker thread) | ~35 µs |
The bare expression called through the .NET binding (9.3 µs) is within 1 µs of the same work in native Rust (8.4 µs), so crossing from .NET into native code is cheap in itself. The cost is in the per-call path of the decision API and in converting data to and from JSON.
Requirements: .NET 8 SDK; for the native run, Rust (rustup.rs) and, on Windows, the Visual Studio "Desktop development with C++" workload (the MSVC linker).
cd CeVsZen
dotnet run -c Release -- check # six hand-made cases against the Code Effects rule
dotnet run -c Release -- verify # all 100,000 orders through Code Effects and both GoRules paths; must report 0 mismatches
dotnet run -c Release # verifies again, then runs BenchmarkDotNet (results in BenchmarkDotNet.Artifacts)
dotnet run -c Release -- export # writes data/orders.jsonl and data/expected.txt for the native run
cd ../ZenNative
cargo run --release # verifies all 100,000 orders against Code Effects' answers, then times five cases
Close other heavy applications first. The .NET benchmark takes roughly 5 to 15 minutes.
- Correctness first. Both programs refuse to report timings unless every engine and every path gives the same answer as Code Effects for all 100,000 orders.
- GoRules' best configurations are included, not only the typical one: input converted to JSON before timing starts, the bare compiled expression with no decision graph, the parallel batch API, and a native Rust build with a precompiled decision and full link-time optimization.
- Serialization is reported separately, so the cost of producing JSON is visible on its own and not hidden in the totals.
- Code Effects evaluates live objects. That is how it is designed to be used: the rule is compiled to .NET code that reads the object's properties directly. No serialization is involved.
- .NET timings use BenchmarkDotNet 0.15.8 (3 warmup and 10 measured iterations, each a full pass over the 100,000 orders, reported per evaluation). Native Rust timings use the same scheme with
std::time::Instant. - Package versions:
CodeEffects.Rule.Engine.Personal7.0.4.39 andGoRules.ZenEngine2.1.9 from nuget.org;zen-engineandzen-expression2.1.8 from crates.io (the newest crates when the test was run). The Personal package of Code Effects is free for personal, community, development and research use and evaluates at full speed. - One machine. The ratios matter more than the absolute numbers. Results from other hardware and operating systems are welcome as pull requests in
results/.
These numbers describe the GoRules versions listed above. If a later release changes its .NET binding, the benchmark can be re-run as is.
CeVsZen/ .NET 8 project: source object, both rules, checks, verification, BenchmarkDotNet suite, data export
ZenNative/ Rust project: GoRules ZEN Engine called in-process on the exported data
results/ raw results, one folder per machine and date
data/ generated by the export step (not committed)
The benchmark code is MIT licensed (see LICENSE). The referenced packages keep their own licenses.