Code Effects vs Rust Rules Engines:
What a Rust Engine Costs a .NET Application

Short answer: Rust rules engines such as the GoRules ZEN Engine are written once in Rust and reached from other languages through bindings, with the application's data passed in as JSON. Code Effects is a .NET rules engine that compiles each rule into .NET code and evaluates the application's own objects in-process. In a reproducible benchmark of the same rule on the same 100,000 orders, Code Effects evaluated the rule in 0.31 µs in a .NET application. 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 the input already converted to the engine's own value type. A Rust engine is the stronger fit when one rule must run in several languages; Code Effects is the faster fit for rules that run in .NET applications.

The full code, data generator and raw results are on GitHub: Rule.Benchmark.DotNetVsRustEngine.

Code Effects vs a Rust Rules Engine at a Glance

Dimension Code Effects GoRules ZEN Engine (Rust)
Engine Managed .NET Standard 2.0 library: .NET Framework 4.6.2+, .NET Core 2.0+, .NET 8+, on Windows, Linux and macOS; Java planned for 2027 Rust core with bindings for .NET, Java, Kotlin, Node.js, Python, Go, Swift and WebAssembly; the .NET package targets .NET 8 and bundles a native library per platform
How a rule runs Compiled once into .NET code; reading a field is a property access on the object Interpreted expression language over dynamic values; reading a field is a lookup by name
Data the rule reads The application's own .NET objects, as they are JSON, parsed into the engine's own value type on every call
One thread, from .NET 0.31 µs per evaluation 49.9 µs (input already JSON) to 53.9 µs (serializing each object)
Fastest path, from .NET 0.31 µs 9.3 µs (bare compiled expression, no decision graph)
Best native Rust case n/a 0.88 µs (bare expression, input already in its value type); 12.7 µs for a decision parsing JSON
All cores, from .NET 0.041 µs (Parallel.For) 4.2 µs (batch API, input already JSON)
Memory per evaluation, from .NET 118 B 808 B to 2,736 B
Where it fits best Rules that run in .NET applications One rule shared by services written in several languages

The Test

The rule. Small, but built from the parts real rules are made of: numbers, a list of values, a collection of objects and a collection of strings.

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"

The data is an ordinary C# class, Order, with a Lines collection of OrderLine objects and a Tags collection of strings. In Code Effects, the rule is written in the rule editor against that class and saved as Rule XML, with the line condition as an item rule ("exists Line where Quantity ≥ 10 and Price > 20"). The engine compiles it once and evaluates Order objects directly:

var evaluator = new Evaluator<Order>(ruleXml);
bool held = evaluator.Evaluate(order);

In GoRules, the same logic is a JSON Decision Model with an input node, one expression node and an output node:

total > 500 and country in ['US', 'CA']
  and some(lines, #.quantity >= 10 and #.price > 20)
  and contains(tags, 'priority')

From .NET, its input is JSON:

using var engine = new ZenEngine(null, null);
using var decision = engine.CreateDecision(new JsonBuffer(File.ReadAllBytes("order-decision.json")));

var json = new JsonBuffer(JsonSerializer.SerializeToUtf8Bytes(order, options));
var response = await decision.Evaluate(json, null);   // {"match": true} or {"match": false}

The data. 100,000 distinct orders generated from a fixed seed, identical on every run: 1 to 20 lines and 0 to 5 tags per order, 27.5% of them matching the rule. Evaluating one object 100,000 times would favor whichever engine caches more.

Correctness first. Before any timing is recorded, every order goes through both engines, and the run stops if they disagree on even one. They agreed on all 100,000.

Every reasonable way to call each engine. Measuring only the typical call would invite the fair reply that the test was rigged, so the benchmark also measures GoRules' best cases: orders converted to JSON before timing starts, the bare compiled expression with no decision graph, and the batch API. Serialization is timed on its own, so its cost is visible and not hidden in the totals.

Setup. Code Effects 7.0.4 (the free CodeEffects.Rule.Engine.Personal package from NuGet, which runs at full speed), GoRules.ZenEngine 2.1.9 from NuGet and zen-engine 2.1.8 from crates.io. BenchmarkDotNet with 3 warmup and 10 measured passes over all 100,000 orders, reported per evaluation. Windows 11, Intel Core Ultra 7 155H, .NET 8.

Results from .NET

One thread, time per evaluation:

Time vs Code Effects Memory allocated
Code Effects, live objects 0.31 µs 1× 118 B
GoRules, bare compiled expression, input already JSON 9.3 µs 30× 808 B
GoRules, decision, input already JSON 49.9 µs 161× 1,805 B
GoRules, decision, serializing each order 53.9 µs 174× 2,736 B
Serializing an order to JSON, on its own 2.0 µs 906 B

The GoRules batch API runs each request on its own worker thread inside the Rust library, so it uses every core. Comparing it with single-threaded Code Effects would be unfair to Code Effects, so it's compared with Code Effects running across all cores with Parallel.For:

All cores Time vs Code Effects
Code Effects, live objects, Parallel.For 0.041 µs 1×
GoRules batch, input already JSON 4.2 µs 103×
GoRules batch, serializing each order 6.7 µs 165×

Even the fastest GoRules path from .NET, the bare expression on data that's already JSON, is 30 times slower than Code Effects evaluating the objects the application already holds.

The Same Engine, Natively in Rust

A fair question follows: is the Rust engine slow, or is it the way .NET reaches it? To separate the two, the same orders, decision file and expression were run in a Rust program that calls the engine in-process, with no .NET involved. It got GoRules' best settings: a precompiled decision and a release build with full link-time optimization. It checked all 100,000 results against Code Effects' answers first, and matched every one.

Native Rust, one thread Time vs Code Effects on .NET
Bare expression, input already in the engine's value type 0.88 µs 2.9×
Decision, input already in the engine's value type 5.1 µs 17×
Bare expression, parsing JSON each call 8.4 µs 27×
Decision, parsing JSON each call 12.7 µs 41×
Parsing an order's JSON into the engine's value type, on its own 7.9 µs

Natively, the engine is far faster than through its .NET binding, so most of the 50 µs is not the engine itself. Yet even in its best native case, with no decision around the expression and the data already converted, it's about three times slower than Code Effects on .NET.

Where the Time Goes

Subtracting the measured cases from each other gives an approximate breakdown of one GoRules decision called from .NET. These are derived numbers, not separate measurements, but each comes from a measured case:

Approx. time
Serializing the order in .NET ~2 µs
Parsing it into the engine's value type ~8 µs
Evaluating the decision ~5 µs
The binding's per-call overhead ~35 µs

The per-call overhead comes from how the .NET package calls a decision: every evaluation is an asynchronous call that hands the work to a worker thread inside the Rust library and waits for it. The bare expression, which the package calls directly, shows the difference: 9.3 µs through .NET, within 1 µs of the same work in native Rust (8.4 µs). Crossing from .NET into native code is cheap; the decision API's per-call path is not. A future release of the binding could reduce this part.

Converting the data follows from the design. An engine that serves many languages needs one data format they all share, and that format is JSON. Every caller, native Rust included, must turn its data into JSON, and the engine must parse it into its own values. At about 8 µs per order, parsing takes longer than evaluating the whole decision.

Evaluating is where the two designs differ most. GoRules interprets its expression over dynamic values, so #.quantity is a lookup by name on every evaluation. Code Effects compiles the rule into .NET code once, so reading Quantity is an ordinary property access on the object the application already has: no serialization, no parsing, no lookup by name.

Two Designs: Compiled for the Platform vs One Core with Bindings

The results don't show that Rust is slow. Natively, the GoRules engine is quick. They show what an application pays to reach an engine built for every language: data conversion on every call, an interpreter instead of compiled code and, in today's .NET binding, the per-call overhead. Any rules engine that serves many languages from one native core shares the first two costs, whatever its language; the measured figures here are GoRules'.

Reaching every language is a real advantage when one rule must run in several stacks, for example in a company whose services are split between .NET, Java and Python. But most rules run where the application runs. For a .NET application, the bindings add no capability, only a cost paid on every evaluation. Teams rarely move their core platform for a new product; they choose tools built for the platform their main systems already use. For that common case, an engine native to the platform is the faster design, and one shared core behind many bindings is mainly the more convenient one for its vendor.

The difference grows with volume. At 50 µs per evaluation, one core evaluates about 20,000 orders per second through the GoRules .NET binding. At 0.31 µs, Code Effects evaluates more than 3 million.

Where a Rust Engine Genuinely Wins

One engine and one rule file that behave the same in .NET, Java, Node.js, Python, Go and on mobile is a strong answer for polyglot organizations, edge devices and teams outside .NET, where Code Effects is planned for Java in 2027 and isn't available today. For services written in Rust, the engine runs natively with no binding at all. And next to rules engines written in Python or JavaScript, a Rust core is fast. See Code Effects vs GoRules for the full product comparison, including rule management, AI and licensing.

Where Code Effects Wins

For rules that run in .NET applications, Code Effects is faster on every measured path: about 160 times faster than the GoRules .NET binding on one thread, 100 times on all cores, and 3 times faster than the GoRules engine's best native Rust case. It allocates a fraction of the memory per evaluation, evaluates the application's own objects with no JSON mapping in between, and ships as a managed .NET Standard 2.0 library, with no native binary to deploy and security-review for each operating system and processor.

Fairness and Limits

  • One machine. The ratios matter more than the absolute times. Results from other hardware and operating systems are welcome as pull requests to the repository.
  • One rule. A rule with a decision table, many branches or calls to the application's own methods would weigh differently. The repository makes it easy to try others.
  • Versions. These results are for GoRules.ZenEngine 2.1.9, zen-engine 2.1.8 and Code Effects 7.0.4. If a later GoRules release makes its .NET binding faster, this page will be updated with new numbers.

Reproduce the Results

Clone the repository and run, with the .NET 8 SDK installed:

cd CeVsZen
dotnet run -c Release -- verify    # both engines on all 100,000 orders; must report 0 mismatches
dotnet run -c Release              # verifies again, then runs the BenchmarkDotNet suite

For the native Rust run, install Rust from rustup.rs (on Windows, also the Visual Studio C++ workload for the linker), then:

dotnet run -c Release -- export    # in CeVsZen: writes the same orders for the Rust program
cd ../ZenNative
cargo run --release

The Code Effects rule editor and engine are free for personal, community, development and research use, as the CodeEffects.Rule.Editor.Personal and CodeEffects.Rule.Engine.Personal packages on NuGet. See rule evaluation and what's new in version 7.

FAQ

Is a Rust rules engine faster than a .NET rules engine? Not when it's called from a .NET application. In this benchmark, Code Effects evaluated the rule in 0.31 µs, and the GoRules ZEN Engine took about 50 µs through its .NET binding. Even natively in Rust, the engine's best case was 0.88 µs, about three times slower than Code Effects on .NET.

Why is the GoRules engine slower through its .NET binding than natively? Each decision call from .NET is an asynchronous call handed to a worker thread inside the Rust library, which costs about 35 µs per evaluation in this test. The data also has to be serialized to JSON in .NET and parsed by the engine, about 10 µs together. Crossing from .NET into native code is cheap in itself.

Does Code Effects need to serialize data to evaluate a rule? No. Code Effects compiles each rule into .NET code once and evaluates the application's own objects in-process, reading their properties directly.

Does the GoRules batch API close the gap? No. The batch API runs requests in parallel on all cores, taking 4.2 µs per evaluation with the input already in JSON. Code Effects running on all cores with Parallel.For took 0.041 µs.

When is a Rust rules engine the better choice? When one rule must run in services written in several languages, on mobile or edge devices, in Rust services, or on platforms Code Effects doesn't support today. For rules that run in .NET applications, Code Effects is faster.

Can the benchmark be reproduced? Yes. The code, the data generator and the raw results are public on GitHub (codeeffects-software/Rule.Benchmark.DotNetVsRustEngine), and both programs check all 100,000 results before reporting any timing.

l102

p101

×