Samples a View3D's renderStats at a fixed interval and writes them to a CSV file. More...
| Import Statement: | import Clayground.Canvas3D |
BenchLogger is a non-visual helper for automated performance benchmarks. While running is true it takes a sample every intervalMs milliseconds from the target View3D and appends one CSV row per sample through a small C++ file writer (QML cannot write files directly).
The fixed columns are: t_ms, fps, frame_ms, sync_ms, prepare_ms, render_ms, gpu_ms, draw_calls, draw_vertices. One extra column is appended for every key in extra, followed by a final note column.
The file is flushed after every sample and closed when logging stops or the component is destroyed, so partial runs still yield valid data.
Example usage:
import QtQuick import QtQuick3D import Clayground.Canvas3D View3D { id: view anchors.fill: parent BenchLogger { id: bench view3D: view outputPath: "/tmp/bench.csv" intervalMs: 250 extra: ({ "boxes": function() { return spawner.count } }) running: true onSampleTaken: console.log("sample written") } }
See also PerfHud.
extra : var |
Map of extra column name to value or zero-argument function. Each entry adds one CSV column; functions are evaluated per sample. The key set is captured when logging starts.
intervalMs : int |
Sampling interval in milliseconds.
outputPath : string |
Destination CSV file path (plain path or file:// URL).
running : bool |
Set true to open the file and start sampling, false to flush, close and stop.
view3D : var |
The View3D whose renderStats are sampled. Required.
sampleTaken() |
Emitted after a sample row has been written.
Note: The corresponding handler is onSampleTaken.
void annotate(string key, var value) |
Adds a one-shot note to the next sample's note column.
Records key = value as a key=value note on the next sample. Multiple notes before a sample are joined with ';'.