Introducing Prism

A tool that helps us optimize our code

Image for post
Image for post

The backstory

Getting to know prism through a simple example

Targets

Running prism

prism profile --profile-target github.com/geckoboard/test/main \
--profile-label="Initial code" \
$GOPATH/src/github.com/geckoboard/test
Image for post
Image for post
Capturing a baseline profile from the initial code
prism print ~/prism/profile-*
Image for post
Image for post
Printing the profile captured from the initial code
prism print --display-threshold 0.1 ~/prism/profile-*
Image for post
Image for post
Applying a threshold to displayed values
prism print --display-format=percent \
--display-columns=total \
~/prism/profile-*
Image for post
Image for post
Displaying the time breakdown as a percentage of total execution time
prism diff --display-columns=total ~/prism/profile-*
Image for post
Image for post
Comparing the optimized code with the original code
ls ~/prism/profile-* | 
tail -2 |
xargs prism diff --display-columns=total
Image for post
Image for post
Comparing the last optimization step against the previous step
prism diff --display-columns=total ~/prism/profile-*
Image for post
Image for post
Comparing each optimization step against the initial implementation

Behind the scenes: how it works

Building the call graph

Navigating the AST and injecting the profiler

Running the patched package

Bonus stuff: prism git-fu

Conclusion

Geckoboard: Under The Hood

Stories, lessons, projects and insights from Geckoboard: a…

Achilleas Anagnostopoulos

Written by

Sr. Software Engineer at Geckoboard / https://github.com/achilleasa

Geckoboard: Under The Hood

Stories, lessons, projects and insights from Geckoboard: a growing SaaS startup building live TV dashboard software to help teams get aligned.

Achilleas Anagnostopoulos

Written by

Sr. Software Engineer at Geckoboard / https://github.com/achilleasa

Geckoboard: Under The Hood

Stories, lessons, projects and insights from Geckoboard: a growing SaaS startup building live TV dashboard software to help teams get aligned.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store