Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
The code previously used Jason.encode! but Jason.encode_to_iodata! should be preferred over IO devices. This should increase performance and reduce memory usage. This is what frameworks such as a Phoenix would have used by default
The code was not encoding App.Device structs in the first test, but regular maps/dictionaries, which meant it could not preallocate the key data (an optimization I am certain the Go runtime performs)
Ensure the datetime is encoded once in second test. The Go test was also encoding once, but the Elixir one did it four times (twice when encoding to JSON, twice when writing to the database)
Bypass Ecto (a relational mapper) and use a direct query when inserting records. That's exactly what the Go benchmark does, which should make a large impact