DalaDev.Profiling (dala_dev v0.2.0)

Copy Markdown View Source

Performance profiling for dala Elixir nodes using :eprof and :fprof.

Provides CPU profiling, flame graphs, and performance analysis for dala Elixir cluster nodes.

Examples:

# Profile a function on a node
{:ok, profile} = DalaDev.Profiling.profile(
  :"dala_qa@192.168.1.5",
  fn -> MyApp.heavy_computation() end
)

# Analyze profile
{:ok, analysis} = DalaDev.Profiling.analyze(profile)

# Generate flame graph (HTML)
DalaDev.Profiling.flame_graph(profile, "flame.html")

Summary

Functions

Analyze profile data and generate a summary.

Generate a flame graph from profile data.

Profile a function on a remote node using :eprof.

Types

analysis()

@type analysis() :: map()

node_ref()

@type node_ref() :: node() | DalaDev.Device.t() | String.t()

profile_data()

@type profile_data() :: term()

Functions

analyze(profile)

@spec analyze(profile_data()) :: {:ok, analysis()} | {:error, term()}

Analyze profile data and generate a summary.

Returns a map with:

  • :total_time - Total execution time
  • :calls - Number of function calls
  • :top_functions - List of {module, function, time, calls}
  • :bottlenecks - Functions with highest time consumption

flame_graph(profile, opts \\ [])

@spec flame_graph(
  profile_data(),
  keyword()
) :: {:ok, String.t() | :ok} | {:error, term()}

Generate a flame graph from profile data.

Options:

  • :format - :html (default) or :text
  • :output - Output file path (optional)

Returns the report content or :ok if saved to file.

profile(node_ref, fun, opts \\ [])

@spec profile(node_ref(), (-> any()), keyword()) ::
  {:ok, profile_data()} | {:error, term()}

Profile a function on a remote node using :eprof.

Options:

  • :timeout - RPC timeout in ms (default: 60_000)
  • :duration - Profile duration in ms (default: 10_000)

Returns {:ok, profile_data} or {:error, reason}.