Created
July 8, 2016 12:15
-
-
Save taylonr/bdec86d515e926ad55cc97a31153a47c to your computer and use it in GitHub Desktop.
Compile String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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