Created
May 27, 2015 11:43
-
-
Save styx/b4810ddd968062ed1d23 to your computer and use it in GitHub Desktop.
Elixir profiling
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
defmodule Test do | |
def run do | |
Enum.each(1..50, &simulated_bottleneck/1) | |
end | |
defp simulated_bottleneck(x) do | |
:timer.sleep(x) | |
end | |
end | |
defmodule Profiler do | |
def profile(fun) do | |
:fprof.apply(fun, [], file: 'profile.trace') | |
:fprof.profile({:file, 'profile.trace'}) | |
:fprof.analyse(dest: 'profile.analyse') | |
File.rm("profile.trace") | |
File.read!("profile.analyse") |> IO.puts | |
File.rm("profile.analyst") | |
end | |
end | |
Profiler.profile(fn -> Test.run end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment