DEV Community

Zenql
Zenql

Posted on

ZenQL vs LINQ: A Performance Snapshot

We want to start with respect: we genuinely love C# LINQ.

It’s an elegant piece of engineering, and ZenQL is inspired by LINQ (and Java Streams).

ZenQL was built around the same core idea: expressive query pipelines with strong performance in Go.

Benchmark Snapshot: ZenQL vs LINQ

Model

type ComplexObjectToSearch struct {
    Name string
    Age  int
    Id   int
    Flag bool
}

Enter fullscreen mode Exit fullscreen mode

ZenQL


contracts.SetMaxAllocGuard(25000000) // we had to remove some safety features.


result := From(&items).Where(func(search ComplexObjectToSearch) bool {
    return search.Name == "Jane" && search.Flag == false
}).Collect()

result2 := From(&result).Any(func(search ComplexObjectToSearch) bool {
    return (search.Name != "Jane") || (search.Flag != false)
}).Assert()

if result2 {
    b.Error("result should be false")
}

Enter fullscreen mode Exit fullscreen mode

LINQ

GC.Collect();
GC.WaitForPendingFinalizers();
long memoryBefore = GC.GetTotalMemory(true);
var sw = Stopwatch.StartNew();

var result = items
    .Where(search => search.Name == "Jane" && search.Flag == false)
    .ToList();

bool result2 = result.Any(search => search.Name != "Jane" || search.Flag != false);

sw.Stop();

Enter fullscreen mode Exit fullscreen mode

Result (in our test setup)

ZenQL: 3236610 ns (~ 3.2 ms )
LINQ: 853073800 ns (~ 853 ms)
Enter fullscreen mode Exit fullscreen mode

Note: Benchmark numbers are environment-dependent.

We recommend reproducing this benchmark on your own machine and workload. As with any benchmark, these results are not definitive—they are intended to provide a practical view of ZenQL’s performance.

Videos and details:

the videos available at our telegram channel for more information. dont forget to star the repo.

Telegram

ZenQL-Repository

Top comments (2)

Collapse
 
benjamin_nguyen_8ca6ff360 profile image
Benjamin Nguyen

Nice! I never try snapshot. Did you had any challenges?

Collapse
 
zenql profile image
Zenql

Thank you, by "snapshot" I mean just a small comparison between ZenQL and LINQ. It's not related to any specific technology.