This repository was created to compare golang and javascript implementations of deep search with a json.
Both go and js implementations are tested with the same data.
The results are very similar probably because I don't know go at all (github copilot did all of the work here), I expected go to be way faster.
- Given an array of objects, it must return all the objects that have the string in any value inside the object.
- Must return the object even if the string is inside a deeply nested object, no matter how many levels deep.
Both implementations are very similar and using the same dataset with 19547 records
language | sensitive case | insensitive case |
---|---|---|
golang | 6ms | 32ms |
javascript | 23ms | 33ms |
You get the same results in go or js in about the same time. When it's not an insensitive implementation you get different results, go was taking around 6~7ms and js was taking around 23~24ms, in this case go was 3~4 times faster than js.
I learned a little bit of go, so it's a win for me regardless.
- Double check both implementations, if you search any genre you get different results, for example
Science Fiction
returns 1473 results in js and 25 in go, it's probably a js quirk wheretypeof [] === 'object'
. - Get memory usage and cpu usage of both implementations.
- Create a backend and frontend to query both implementations.
- Test with fuzzy search.
- Test with different data.
- Try a more manual implementation instead of using the language features.
- Get a bigger average time, maybe with some scripts.
You need both node and go installed to run this example
- cd into
apps/js/js-search
- run
yarn
ornpm install
- run
yarn dev
- cd into
apps/go/go-search
- run
go run main.go