Koazee vs Go-Funk vs Go-Linq

Iván Corrales Solera
Wesovi Labs
Published in
3 min readDec 4, 2018

The purpose of this article is providing a benchmark comparison between Koazee and two of the most well-known Golang frameworks to work with arrays: Go-Funk and Go-Linq.

Sources

The repository used to create the benchmark comparison can be found on my Github organization, https://github.com/wesovilabs/koazee-comparison

Comparison

The benchmark tests can be run from your own computer, code can be download from here

For this comparison I’ve been focused on how the 3 frameworks deals with arrays of primitive types.

The below graph shows how is the frameworks performance for each test:

The axis-y shows the ns/op per operation and axis-x the different tests. As we can observe, the performance in Koazee is much better for all the scenarios.

The tests are described below:

  • Sum: Given an array with 5000 random numbers we must find the sum of all its elements.

Koazee: 18014 ns/op GoLinq: 239511 ns/op GoFunk: 2096351 ns/op

  • Duplicate: Given an array with 5000 random numbers we must return another array where each element has been multiplied by 2

Koazee: 28762 ns/op GoLinq: 456650 ns/op GoFunk: p1816872 ns/op

  • Reverse: Given an array with 5000 random numbers we must reverse the sequences of numbers

Koazee: 21462 ns/op GoFunk: 167916 ns/op GoLinq: 503982 ns/op

Sort: Given an array with 5000 random numbers we must return an array with the elements ascending ordered.

Koazee: 570380 GoLinq: 1882618 ns/op

(*)Probably, It’s my fault but I didn’t find a way to perform this action in GoFunk

Filter: Given an array with 5000 random we will return an array with only the odd elements.

Koazee: 111382 ns/op GoLinq: 326412 ns/op GoFunk: 1748583 ns/op

Contains: Given an array with 5000 random numbers we must return if the element in the last position is found or not

Koazee: 3607 ns/op GoFunk: 248290 ns/op GoLinq: 107764 ns/op

Multiple operations: Given an array with 5000 random strings, we need to perform the below operations:

  • Sort the strings ascending
  • Reverse the sequence of strings
  • Filter the array and discard those words whose len is not 4.
  • Convert array of string into an array of int, where the new elements will be the length of the word. (Obviously all the elements in the new array will be 4 after the applied filter in the previous step)
  • Sum all the elements

Koazee: 2447864 ns/op GoLinq: 3096456 ns/op

(*) GoFunk doesn’t provide a way to concatenate operations

Conclussions

  • Koazee is the youngest, and the set of provided operations is poor. Basically It’s only one month since I started coding it and most of time I’ve been focused on improving performance.
  • It’s clear that performance in Koazee is much better.

Implement new operations is easy, doing better than others is the most complicated part

  • Koazee is the only one that provides us with the error in case of something didn’t work as expected, make it the safest library.
  • GoFunk doesn’t provide a friendly way to concatenate operations as Koazee or GoLinq do.
  • Koazee is the only that doesn’t force you to cast function inputs while you’re defining your operations.

For future release Koazee v0.0.3 I would like to provide a richer set of operations over arrays. but always, being focused on providing the best performance.

If you like the project, the article or just think this project deserves being supported, I would really appreciate if you share it on your networks , tweet the article or star the repository in Github

--

--