class

Ctop::Collectors::Base(T)

Inherits Reference < Object

Base class for all collectors providing shared timing utilities.

Generic type T represents the Snapshot type returned by collect. Each collector defines its own Snapshot record and inherits from Base(Snapshot).

class CPU < Base(CPU::Snapshot)
  record Snapshot, usage : Float64

  def collect : Snapshot
    Snapshot.new(usage: 50.0)
  end
end

Instance methods

collect

Collect metrics and return an immutable snapshot

Source
reset_timing

Reset timing state (useful for tests)

Source