mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-04-06 10:26:02 +00:00
Statistic reports mainly packets per second
This commit is contained in:
33
src/Network 2.0/StatMonitor.cpp
Normal file
33
src/Network 2.0/StatMonitor.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 6/18/2020
|
||||
///
|
||||
#include "Client.hpp"
|
||||
#include <string>
|
||||
#include <thread>
|
||||
std::string StatReport = "-";
|
||||
int PPS = 0;
|
||||
[[noreturn]] void Monitor(){
|
||||
int R,C;
|
||||
while(true){
|
||||
if(Clients.empty()){
|
||||
StatReport = "-";
|
||||
}else{
|
||||
C = 0;
|
||||
for(Client *c : Clients){
|
||||
if(c->GetCarCount() > 0)C++;
|
||||
}
|
||||
if(C == 0 || PPS == 0){
|
||||
StatReport = "-";
|
||||
}else{
|
||||
R = PPS/C;
|
||||
StatReport = std::to_string(R);
|
||||
}
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
void StatInit(){
|
||||
std::thread Init(Monitor);
|
||||
Init.detach();
|
||||
}
|
||||
Reference in New Issue
Block a user