mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-15 04:49:06 +01:00
eu07 --test -s <scenery> [--test-timeout <s>] runs the scenery in ghostview with
the null renderer (models loaded, no textures), a hidden window, no sound,
network or python, and in fixed steps of 0.03 s of simulation time per frame
(three 10 ms physics steps) as fast as it can. Without -seed it uses a fixed
seed, so two runs give byte-identical physicslogs.
The scenery reports its result to the __test.result memory cell, which the
simulator always creates: value 1 passes once every vehicle has stood still for
1 s, value 0 fails at once. The run ends with exit code
0 pass, 1 fail,
2 a train passed a signal at stop (SetVelocity 0 0, as seen in its driver's
speed table; SetVelocity 0 x on automatic block doesn't count),
3 timeout (test.timeout, default 3600 s of simulation time),
4 standstill (every vehicle still for test.standstill s, default 300, with no
result; a pass with test.pass_on_standstill yes),
5 error (no -s, the scenery didn't load or has no vehicles, an exception).
The test.* keys go in the scenery's config block; test.fail_if_stop_overran no
only logs a signal passed at danger. Outside the test mode a signal passed at
danger is logged.
The null renderer gets a ui backend which draws nothing, hands out the null
texture and material instead of throwing, and ends the ui frame. A GL context
is still made for the hidden window, without asking for a version, as parts
of the ui create textures with gl calls of their own. No crash dialog or
message box in test mode; the window code no longer needs a monitor.
77 lines
1.8 KiB
C++
77 lines
1.8 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
namespace Timer {
|
|
|
|
double GetTime();
|
|
double GetRenderTime();
|
|
|
|
double GetDeltaTime();
|
|
double GetDeltaRenderTime();
|
|
|
|
void set_delta_override(double v);
|
|
|
|
// every frame advances the clocks by this many seconds, whatever the real time; 0 = real time (test mode)
|
|
void set_fixed_step(double v);
|
|
|
|
void ResetTimers();
|
|
|
|
void UpdateTimers(bool pause);
|
|
|
|
class stopwatch {
|
|
|
|
public:
|
|
// constructors
|
|
stopwatch() = default;
|
|
// methods
|
|
void
|
|
start() {
|
|
m_start = std::chrono::steady_clock::now(); }
|
|
std::chrono::duration<float, std::milli>
|
|
stop() {
|
|
m_last = std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::steady_clock::now() - m_start );
|
|
m_accumulator = 0.95f * m_accumulator + static_cast<float>(m_last.count()) / 1000.f;
|
|
return m_last; }
|
|
float
|
|
average() const {
|
|
return m_accumulator / 20.f;}
|
|
std::chrono::microseconds
|
|
last() const {
|
|
return m_last; }
|
|
|
|
private:
|
|
// members
|
|
std::chrono::time_point<std::chrono::steady_clock> m_start { std::chrono::steady_clock::now() };
|
|
float m_accumulator { 1000.f / 30.f * 20.f }; // 20 last samples, initial 'neutral' rate of 30 fps
|
|
std::chrono::microseconds m_last;
|
|
};
|
|
|
|
struct subsystem_stopwatches {
|
|
stopwatch gfx_total;
|
|
stopwatch gfx_color;
|
|
stopwatch gfx_shadows;
|
|
stopwatch gfx_reflections;
|
|
stopwatch gfx_swap;
|
|
stopwatch gfx_gui;
|
|
stopwatch gfx_animate;
|
|
stopwatch sim_total;
|
|
stopwatch sim_dynamics;
|
|
stopwatch sim_events;
|
|
stopwatch sim_ai;
|
|
stopwatch mainloop_total;
|
|
};
|
|
|
|
extern subsystem_stopwatches subsystem;
|
|
|
|
};
|
|
|
|
//---------------------------------------------------------------------------
|