Skip to content

v1.7.9 (Thor Api Memory Optimizations)

Choose a tag to compare

@malikhan-dev malikhan-dev released this 07 Jun 09:31
· 42 commits to main since this release
8c30277

Thor Api

  • the From() function accepts pointers from now on.

  • memory allocations reduced dramatically.

  • huge performance improvement.

new way:

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

benchmark on 50,000,000 records filter:

  goos: linux
  goarch: amd64
  pkg: github.com/malikhan-dev/zenql/collections/Thor
  cpu: 12th Gen Intel(R) Core(TM) i7-12700H
  BenchmarkQueryEngine
  BenchmarkQueryEngine-20               88          13636313 ns/op        22727310 B/op          0 allocs/op
at Thor_Engine__test.go 

func BenchmarkQueryEngine(b *testing.B) {

	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")
	}

} 

database module

dynamic database for each test run added for postgresql