mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-29 19:47:30 +01:00
perf(debug): count what keeps the physics on in rail vehicles standing still (active cab, speed, acceleration, switching, ezt/dmu, moving neighbour), for the debug panel
This commit is contained in:
@@ -869,6 +869,13 @@ void opengl46_renderer::SwapBuffers()
|
|||||||
count( counts.kind[ kind ] ) + " " + count( counts.standing[ kind ] ) + " " + ms( timers.vehicles_forces_kind[ kind ].average() ) + " "
|
count( counts.kind[ kind ] ) + " " + count( counts.standing[ kind ] ) + " " + ms( timers.vehicles_forces_kind[ kind ].average() ) + " "
|
||||||
+ ms( timers.vehicles_update_kind[ kind ].average() ) );
|
+ ms( timers.vehicles_update_kind[ kind ].average() ) );
|
||||||
}
|
}
|
||||||
|
auto const &awake { counts.awake };
|
||||||
|
text += timeline(
|
||||||
|
3,
|
||||||
|
std::to_string( awake.vehicles ) + " rail standing with physics on: cab " + std::to_string( awake.cab ) + ", speed " + std::to_string( awake.speed )
|
||||||
|
+ ", acceleration " + std::to_string( awake.acceleration ) + ", switching " + std::to_string( awake.switching ) + ", ezt/dmu "
|
||||||
|
+ std::to_string( awake.multipleunit ) + ", neighbour " + std::to_string( awake.neighbour ),
|
||||||
|
"" );
|
||||||
}
|
}
|
||||||
text += timeline( 2, "secondary steps", ms( timers.sim_secondary.average() ) );
|
text += timeline( 2, "secondary steps", ms( timers.sim_secondary.average() ) );
|
||||||
text += timeline( 2, "trains (cabs)", ms( timers.sim_trains.average() ) );
|
text += timeline( 2, "trains (cabs)", ms( timers.sim_trains.average() ) );
|
||||||
|
|||||||
@@ -126,6 +126,17 @@ struct subsystem_stopwatches {
|
|||||||
// enabled vehicles of each kind (see vehicles_forces_kind), and of them the ones standing still
|
// enabled vehicles of each kind (see vehicles_forces_kind), and of them the ones standing still
|
||||||
std::array<unsigned int, 4> kind {};
|
std::array<unsigned int, 4> kind {};
|
||||||
std::array<unsigned int, 4> standing {};
|
std::array<unsigned int, 4> standing {};
|
||||||
|
// rail vehicles standing still (below 0.01 km/h) with the physics on, and what keeps it on by the test of
|
||||||
|
// TMoverParameters::ComputeTotalForce(); a vehicle can have several of these
|
||||||
|
struct awake_reasons {
|
||||||
|
unsigned int vehicles { 0 };
|
||||||
|
unsigned int cab { 0 }; // CabActive
|
||||||
|
unsigned int speed { 0 }; // Vel above 0.0001 km/h
|
||||||
|
unsigned int acceleration { 0 }; // AccS above 0.0001 m/s2
|
||||||
|
unsigned int switching { 0 }; // LastSwitchingTime below 5 s
|
||||||
|
unsigned int multipleunit { 0 }; // EZT, DMU
|
||||||
|
unsigned int neighbour { 0 }; // a neighbour moving or accelerating
|
||||||
|
} awake;
|
||||||
};
|
};
|
||||||
vehicle_counts vehicles; // of the frame under way
|
vehicle_counts vehicles; // of the frame under way
|
||||||
vehicle_counts vehicleslast; // of the last frame
|
vehicle_counts vehicleslast; // of the last frame
|
||||||
|
|||||||
@@ -8614,6 +8614,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) {
|
|||||||
counts.enabled = counts.road = counts.ai = counts.active = 0;
|
counts.enabled = counts.road = counts.ai = counts.active = 0;
|
||||||
counts.kind = {};
|
counts.kind = {};
|
||||||
counts.standing = {};
|
counts.standing = {};
|
||||||
|
counts.awake = {};
|
||||||
counts.steps += static_cast<unsigned int>( std::max( Iterationcount, 1 ) );
|
counts.steps += static_cast<unsigned int>( std::max( Iterationcount, 1 ) );
|
||||||
// the kind of each vehicle: rail or road, near the camera or farther. the time of each vehicle in the loops below goes to its
|
// the kind of each vehicle: rail or road, near the camera or farther. the time of each vehicle in the loops below goes to its
|
||||||
// kind, measured from the end of the one before it
|
// kind, measured from the end of the one before it
|
||||||
@@ -8627,7 +8628,24 @@ vehicle_table::update( double Deltatime, int Iterationcount ) {
|
|||||||
kinds[ index ] = static_cast<std::uint8_t>( ( road ? 2 : 0 ) + ( distant ? 1 : 0 ) );
|
kinds[ index ] = static_cast<std::uint8_t>( ( road ? 2 : 0 ) + ( distant ? 1 : 0 ) );
|
||||||
if( false == vehicle->bEnabled ) { continue; }
|
if( false == vehicle->bEnabled ) { continue; }
|
||||||
++counts.kind[ kinds[ index ] ];
|
++counts.kind[ kinds[ index ] ];
|
||||||
if( vehicle->MoverParameters->Vel < 0.01 ) { ++counts.standing[ kinds[ index ] ]; }
|
auto const *mover { vehicle->MoverParameters };
|
||||||
|
if( mover->Vel < 0.01 ) {
|
||||||
|
++counts.standing[ kinds[ index ] ];
|
||||||
|
if( ( false == road ) && mover->PhysicActivation ) {
|
||||||
|
// the test of TMoverParameters::ComputeTotalForce(), part by part
|
||||||
|
auto const moving = []( neighbour_data const &Neighbour ) {
|
||||||
|
return ( Neighbour.vehicle != nullptr )
|
||||||
|
&& ( ( Neighbour.vehicle->MoverParameters->Vel > 0.0001 ) || ( std::abs( Neighbour.vehicle->MoverParameters->AccS ) > 0.0001 ) ); };
|
||||||
|
auto &awake { counts.awake };
|
||||||
|
++awake.vehicles;
|
||||||
|
if( mover->CabActive != 0 ) { ++awake.cab; }
|
||||||
|
if( mover->Vel > 0.0001 ) { ++awake.speed; }
|
||||||
|
if( std::abs( mover->AccS ) > 0.0001 ) { ++awake.acceleration; }
|
||||||
|
if( mover->LastSwitchingTime < 5 ) { ++awake.switching; }
|
||||||
|
if( ( mover->TrainType == dt_EZT ) || ( mover->TrainType == dt_DMU ) ) { ++awake.multipleunit; }
|
||||||
|
if( moving( mover->Neighbours[ end::front ] ) || moving( mover->Neighbours[ end::rear ] ) ) { ++awake.neighbour; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto const lap = [ & ]( std::size_t const Index, std::array<Timer::frame_stopwatch, 4> &Times, std::chrono::steady_clock::time_point &Mark ) {
|
auto const lap = [ & ]( std::size_t const Index, std::array<Timer::frame_stopwatch, 4> &Times, std::chrono::steady_clock::time_point &Mark ) {
|
||||||
auto const now { std::chrono::steady_clock::now() };
|
auto const now { std::chrono::steady_clock::now() };
|
||||||
|
|||||||
Reference in New Issue
Block a user