MobDev.Bench.Logger (mob_dev v0.5.9)

Copy Markdown View Source

Append-only CSV log of bench probe snapshots.

Format:

ts_ms,elapsed_sec,reachability,app_process,usb,screen,battery_pct,reason

Reading:

  • ts_ms is monotonic — safe to subtract for intervals
  • elapsed_sec is seconds since the run started (set on open/2)
  • reachability, app_process, usb, screen are atoms (string-encoded)
  • battery_pct is integer or empty
  • reason is a string (CSV-escaped)

Use summary/1 after a run to compute % success, gap distribution, reconnect count, etc.

Summary

Functions

Append a probe snapshot. Returns the updated logger struct.

Close the log file. Idempotent.

Open a log file for writing. Creates parent dirs as needed.

Read a CSV file and return a list of probe-like maps. Useful for tests and for summary/1.

Types

t()

@type t() :: %MobDev.Bench.Logger{
  file: File.io_device() | nil,
  path: Path.t(),
  rows: non_neg_integer(),
  start_ts_ms: integer()
}

Functions

append(log, probe)

@spec append(t(), MobDev.Bench.Probe.t()) :: t()

Append a probe snapshot. Returns the updated logger struct.

close(log)

@spec close(t()) :: t()

Close the log file. Idempotent.

open(path, opts \\ [])

@spec open(
  Path.t(),
  keyword()
) :: t()

Open a log file for writing. Creates parent dirs as needed.

Returns a struct that's passed to subsequent append/2 and close/1 calls.

read(path)

@spec read(Path.t()) :: [map()]

Read a CSV file and return a list of probe-like maps. Useful for tests and for summary/1.

Each row is %{ts_ms, elapsed_sec, reachability, app_process, usb, screen, battery_pct, reason} with atoms restored.