Add warning when starting benchmark in headless mode

The benchmark API captures per-frame data from the game loop, which is
bypassed when using step()-based simulation control. This warning
informs users to use Python's time module for headless performance
measurement instead.

Also adds test_headless_benchmark.py which verifies:
- step() and screenshot() don't produce benchmark frames
- Wall-clock timing for headless operations
- Complex scene throughput measurement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-12-01 22:20:19 -05:00
commit f2f8d6422f
2 changed files with 174 additions and 0 deletions

View file

@ -1355,6 +1355,14 @@ PyObject* McRFPy_API::_setDevConsole(PyObject* self, PyObject* args) {
// Benchmark logging implementation (#104)
PyObject* McRFPy_API::_startBenchmark(PyObject* self, PyObject* args) {
try {
// Warn if in headless mode - benchmark frames are only recorded by the game loop
if (game && game->isHeadless()) {
PyErr_WarnEx(PyExc_UserWarning,
"Benchmark started in headless mode. Note: step() and screenshot() do not "
"record benchmark frames. The benchmark API captures per-frame data from the "
"game loop, which is bypassed when using step()-based simulation control. "
"For headless performance measurement, use Python's time module instead.", 1);
}
g_benchmarkLogger.start();
Py_RETURN_NONE;
} catch (const std::runtime_error& e) {