Skip to content

Instantly share code, notes, and snippets.

@taylonr
Created July 8, 2016 12:15
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/bdec86d515e926ad55cc97a31153a47c to your computer and use it in GitHub Desktop.
Save taylonr/bdec86d515e926ad55cc97a31153a47c to your computer and use it in GitHub Desktop.
Compile String
def compare(conn, params) do
first = params["code"]["first_snippet"]
second = params["code"]["second_snippet"]
code = """
defmodule Sample do
def benchee do
Benchee.init(%{time: 3})
|> Benchee.benchmark('first snippet', fn -> #{first} end)
|> Benchee.benchmark('second snippet', fn -> #{second} end)
|> Benchee.measure
|> Benchee.statistics
|> BencheeWeb.Formatter.to_map
end
end
"""
Code.compile_string(code)
val = Sample.benchee
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