Raxol.Benchmark.MemoryDSL (Raxol v2.0.1)

View Source

Enhanced DSL for memory benchmarking with advanced assertions.

Phase 3 Implementation: Provides memory-specific assertions and analysis:

  • assert_memory_peak/2 - Peak memory usage assertions
  • assert_memory_sustained/2 - Sustained memory usage assertions
  • assert_gc_pressure/2 - Garbage collection pressure assertions
  • assert_memory_efficiency/2 - Memory efficiency assertions
  • assert_no_memory_regression/2 - Memory regression detection

Usage: use Raxol.Benchmark.MemoryDSL

memory_benchmark "Terminal Operations" do

scenario "large_buffer", fn ->
  create_large_buffer(1000, 1000)
end

assert_memory_peak :large_buffer, less_than: 50_000_000  # 50MB
assert_memory_sustained :large_buffer, less_than: 30_000_000  # 30MB
assert_gc_pressure :large_buffer, less_than: 10  # Max 10 GC collections
assert_memory_efficiency :large_buffer, greater_than: 0.7  # 70% efficiency
assert_no_memory_regression baseline: "v1.5.4"

end

Summary

Functions

Asserts garbage collection pressure is below threshold.

Asserts memory efficiency is above threshold.

Asserts peak memory usage is below threshold.

Asserts sustained memory usage is below threshold.

Asserts no memory regression compared to baseline.

Executes a memory benchmark defined with the DSL.

Defines a memory benchmark suite.

Configures memory benchmark behavior.

Defines a memory benchmark scenario.

Types

assertion_result()

@type assertion_result() :: {:ok, term()} | {:error, String.t()}

efficiency_threshold()

@type efficiency_threshold() :: float()

memory_threshold()

@type memory_threshold() :: non_neg_integer()

Functions

assert_gc_pressure(scenario, opts)

(macro)

Asserts garbage collection pressure is below threshold.

assert_memory_efficiency(scenario, opts)

(macro)

Asserts memory efficiency is above threshold.

assert_memory_peak(scenario, opts)

(macro)

Asserts peak memory usage is below threshold.

assert_memory_sustained(scenario, opts)

(macro)

Asserts sustained memory usage is below threshold.

assert_no_memory_regression(opts)

(macro)

Asserts no memory regression compared to baseline.

execute_memory_benchmark(module, opts \\ [])

Executes a memory benchmark defined with the DSL.

memory_benchmark(name, list)

(macro)

Defines a memory benchmark suite.

memory_config(opts)

(macro)

Configures memory benchmark behavior.

scenario(name, fun)

(macro)

Defines a memory benchmark scenario.