Skip to content

Instantly share code, notes, and snippets.

@taylonr
Created July 8, 2016 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taylonr/4e3c9084e8728771ce1b8b63bbf69d7f to your computer and use it in GitHub Desktop.
Save taylonr/4e3c9084e8728771ce1b8b63bbf69d7f to your computer and use it in GitHub Desktop.
String Eval
def compare(conn, params) do
first = params["code"]["first_snippet"]
second = params["code"]["second_snippet"]
{val, _} = Code.eval_string("Benchee.init(%{time: 3})
|> Benchee.benchmark('First', fn -> #{first} end)
|> Benchee.benchmark('Second', fn -> #{second} end)
|> Benchee.measure
|> Benchee.statistics
|> BencheeWeb.Formatter.to_map")
render conn, "compare.html", vals: val
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment