Skip to content
New issue

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.

Already on GitHub? Sign in to your account

Perf Optimisation: Use EEX Template for SVG Rendering #70

Open
3 tasks
nelsonic opened this issue May 17, 2019 · 1 comment
Open
3 tasks

Perf Optimisation: Use EEX Template for SVG Rendering #70

nelsonic opened this issue May 17, 2019 · 1 comment

Comments

@nelsonic
Copy link
Member

At present we have a 511 Byte template.svg file which we are manually String.replace-ing the {count} in:

 String.replace(svg_badge_template(), ~r/{count}/, to_string(count))

This does not take advantage of Phoenix's template compilation for faster rendering.

Todo

  • refactor template to badge.svg.eex
  • render using render(conn, "badge.svg", count)
  • apply gzip compression for even faster rendering

Note: rendering is not currently a "bottleneck" in the app,
the DB query is orders of magnitude slower than String.replace.
This optimisation should be considered after ETS is implemented for caching the count.

@nelsonic nelsonic changed the title Performance Optimisation: Use EEX Template for SVG Rendering Perf Optimisation: Use EEX Template for SVG Rendering May 17, 2019
@nelsonic
Copy link
Member Author

Using the String.replace method, the response time on localhost is around 500µs:
image

That's µs not ms ... 500 microseconds ... 500 millionths of a second.

We can definitely speed this up, and it would be good to do a more scientific benchmark of response times ... but I don't think any one is going to complain about this response time. 😉

Still if you have time to help refactor this, please dive in! 💻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant