DalaDev.Benchmark (dala_dev v0.0.7)

Copy Markdown View Source

Runtime benchmarking for dala Elixir nodes.

Measure execution time, memory usage, reductions, and compare performance across different devices in the cluster.

Examples

# Measure a function on a remote node
{:ok, result, stats} = DalaDev.Benchmark.measure(
  :"dala_qa@192.168.1.5",
  fn -> MyApp.heavy_computation() end
)

# Compare performance across nodes
DalaDev.Benchmark.compare([node1, node2], test_module: MyBench)

# Profile memory usage
DalaDev.Benchmark.memory_profile(node, duration: 60_000)

Summary

Functions

Compare performance across multiple nodes.

Measure execution time and resource usage of a function on a remote node.

Profile memory usage on a node over time.

Generate a benchmark report.

Types

benchmark_result()

@type benchmark_result() :: %{
  node: node(),
  wall_time: integer(),
  reductions: integer(),
  memory: integer(),
  process_count: integer(),
  message_queue_len: integer()
}

node_ref()

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

Functions

compare(nodes, opts \\ [])

@spec compare(
  [node_ref()],
  keyword()
) :: [benchmark_result()]

Compare performance across multiple nodes.

Options:

  • :test_module - Module containing benchmark functions
  • :test_function - Function to call (default: :run/0)
  • :iterations - Number of iterations per node

Returns a list of benchmark results for comparison.

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

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

Measure execution time and resource usage of a function on a remote node.

Options:

  • :timeout - RPC timeout in ms (default: 30_000)
  • :warmup - Number of warmup iterations (default: 1)
  • :iterations - Number of measurement iterations (default: 1)

Returns {:ok, result, stats} or {:error, reason}.

memory_profile(node_ref, opts \\ [])

@spec memory_profile(
  node_ref(),
  keyword()
) :: {:ok, [map()]} | {:error, term()}

Profile memory usage on a node over time.

Options:

  • :duration - Profile duration in ms (default: 60_000)
  • :interval - Sampling interval in ms (default: 1_000)

Returns memory statistics over time.

report(results, opts \\ [])

@spec report(
  [benchmark_result()],
  keyword()
) :: {:ok, String.t() | :ok} | {:error, term()}

Generate a benchmark report.

Options:

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

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