   end
 
   defp profile_and_analyse(fun, opts) do
+    sorting = case Keyword.get(opts, :sort, "acc") do
+      "acc" -> :acc
+      "own" -> :own
+    end
+
     {:ok, tracer} = :fprof.profile(:start)
     :fprof.apply(fun, [], tracer: tracer)
 

        totals: true,
        details: Keyword.get(opts, :details, false),
        callers: Keyword.get(opts, :callers, false),
        sort:
          case Keyword.get(opts, :sort, "acc") do
            "acc" -> :acc
            "own" -> :own
          end
      )
      {_in, analysis_output} = StringIO.contents(analyse_dest)
      to_char_list(analysis_output)
    after
      StringIO.close(analyse_dest)
    end

  end

  defp filter_patterns(pattern) do
    Path.wildcard(pattern)
    |> Enum.uniq
    |> Enum.filter(&File.regular?/1)
  end

  # Profiling functions

  defp profile_code(code_string, opts) do
    content =
      quote do
        unquote(__MODULE__).profile(fn ->
          unquote(Code.string_to_quoted!(code_string))
        end, unquote(opts))
      end
    # Use compile_quoted since it leaves less noise than eval_quoted
    Code.compile_quoted(content)
  end

  @doc false
