← Back to Docs
  • index.html
  • Clayground
  • Clayground.Canvas3D
  • PerfRegistry
  • Clayground 2026.2
  • PerfRegistry QML Type

    App-wide singleton for measuring named code sections and event rates. More...

    Import Statement: import Clayground.Canvas3D

    Methods

    Detailed Description

    PerfRegistry is a lightweight, dependency-free profiling registry meant to be dropped into any simulation or render loop and read back by a HUD. It has two primitives:

    It is cheap when unused: no timer runs until a section or counter is first touched. PerfHud appends a snapshot of these readings beneath its render stats automatically.

    import Clayground.Canvas3D
    
    // in a per-frame handler:
    PerfRegistry.begin("carSim")
    stepSimulation()
    PerfRegistry.end("carSim")
    
    PerfRegistry.begin("carPack")
    packAndUpload()
    PerfRegistry.end("carPack")

    See also PerfHud and DynamicInstances3D.

    Method Documentation

    void begin(string name)

    Starts timing the section name.


    void end(string name)

    Stops timing the section name and folds it into the rolling average.


    void reset()

    Clears all recorded sections and counters.


    list snapshot()

    Returns the current section averages and counter rates.

    Each element is a map { name, kind, avgMs, rate }: kind is "section" (with avgMs set) or "counter" (with rate set).


    void tick(string name)

    Records one occurrence of the counter name.