Commit 4cc88541 authored by Pavel Vainerman's avatar Pavel Vainerman

(UNet): added processing statistics

parent 83afb896
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
</RTUExchange> </RTUExchange>
<UDPExchange name="UDPExchange"/> <UDPExchange name="UDPExchange"/>
<UDPExchange2 name="UDPExchange2"/> <UDPExchange2 name="UDPExchange2"/>
<UNetExchange name="UNetExchange" transport="multicast"/> <UNetExchange name="UNetExchange" transport1="multicast"/>
<HeartBeatTime msec="5000"/> <HeartBeatTime msec="5000"/>
<NCReadyTimeout msec="120000"/> <NCReadyTimeout msec="120000"/>
<TestGen input1_s="Input1_S" input2_s="DumpSensor1_S" name="TestGen" output1_c="DO_C" output2_c="DO1_C"/> <TestGen input1_s="Input1_S" input2_s="DumpSensor1_S" name="TestGen" output1_c="DO_C" output2_c="DO1_C"/>
......
...@@ -303,13 +303,11 @@ void UNetReceiver::statisticsEvent(ev::periodic& tm, int revents) noexcept ...@@ -303,13 +303,11 @@ void UNetReceiver::statisticsEvent(ev::periodic& tm, int revents) noexcept
return; return;
} }
statRecvPerSec = recvCount; auto t_end = chrono::high_resolution_clock::now();
statUpPerSec = upCount; float sec = chrono::duration_cast<chrono::duration<float>>(t_end - t_stats).count();
t_stats = t_end;
// unetlog9 << myname << "(statisctics):" stats.recvPerSec = recvCount / sec;
// << " recvCount=" << recvCount << "[per sec]" stats.upPerSec = upCount / sec;
// << " upCount=" << upCount << "[per sec]"
// << endl;
recvCount = 0; recvCount = 0;
upCount = 0; upCount = 0;
...@@ -485,6 +483,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept ...@@ -485,6 +483,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
return; return;
bool ok = false; bool ok = false;
t_start = chrono::high_resolution_clock::now();
try try
{ {
...@@ -510,6 +509,9 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept ...@@ -510,6 +509,9 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
std::lock_guard<std::mutex> l(tmMutex); std::lock_guard<std::mutex> l(tmMutex);
ptRecvTimeout.reset(); ptRecvTimeout.reset();
} }
t_end = chrono::high_resolution_clock::now();
stats.recvProcessingTime_microsec = std::chrono::duration_cast<std::chrono::microseconds>(t_end - t_start).count();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UNetReceiver::checkConnection() bool UNetReceiver::checkConnection()
...@@ -565,6 +567,8 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept ...@@ -565,6 +567,8 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
bool recvOk = checkConnection(); bool recvOk = checkConnection();
// обновление данных в SM // обновление данных в SM
t_start = chrono::high_resolution_clock::now();
try try
{ {
update(); update();
...@@ -574,6 +578,9 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept ...@@ -574,6 +578,9 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
unetcrit << myname << "(updateEvent): " << ex.what() << std::endl; unetcrit << myname << "(updateEvent): " << ex.what() << std::endl;
} }
t_end = chrono::high_resolution_clock::now();
stats.upProcessingTime_microsec = std::chrono::duration_cast<std::chrono::microseconds>(t_end - t_start).count();
if( sidRespond != DefaultObjectId ) if( sidRespond != DefaultObjectId )
{ {
try try
...@@ -822,15 +829,20 @@ const std::string UNetReceiver::getShortInfo() const noexcept ...@@ -822,15 +829,20 @@ const std::string UNetReceiver::getShortInfo() const noexcept
<< " lostPackets=" << setw(6) << getLostPacketsNum() << " lostPackets=" << setw(6) << getLostPacketsNum()
<< endl << endl
<< "\t[" << "\t["
<< " recvTimeout=" << setw(6) << recvTimeout << " recvTimeout=" << recvTimeout
<< " prepareTime=" << setw(6) << prepareTime << " prepareTime=" << prepareTime
<< " evrunTimeout=" << setw(6) << evrunTimeout << " evrunTimeout=" << evrunTimeout
<< " lostTimeout=" << setw(6) << lostTimeout << " lostTimeout=" << lostTimeout
<< " updatepause=" << setw(6) << updatepause << " updatepause=" << updatepause
<< " maxDifferens=" << setw(6) << maxDifferens << " maxDifferens=" << maxDifferens
<< " ]" << " ]"
<< endl << endl
<< "\t[ qsize=" << (wnum - rnum) << " recv=" << statRecvPerSec << " update=" << statUpPerSec << " per sec ]"; << "\t[ qsize:" << setw(3) << (wnum - rnum)
<< " recv:" << setprecision(3) << setw(6) << stats.recvPerSec << " msg/sec"
<< " update:" << setprecision(3) << setw(6) << stats.upPerSec << " msg/sec"
<< " upTime:" << setw(6) << stats.upProcessingTime_microsec << " usec"
<< " recvTime:" << setw(6) << stats.recvProcessingTime_microsec << " usec"
<< "]";
return s.str(); return s.str();
} }
......
...@@ -209,10 +209,20 @@ namespace uniset ...@@ -209,10 +209,20 @@ namespace uniset
// счётчики для подсчёта статистики // счётчики для подсчёта статистики
size_t recvCount = { 0 }; size_t recvCount = { 0 };
size_t upCount = { 0 }; size_t upCount = { 0 };
std::chrono::system_clock::time_point t_start;
std::chrono::system_clock::time_point t_end;
std::chrono::system_clock::time_point t_stats;
// текущая статистика // текущая статистика
size_t statRecvPerSec = { 0 }; /*!< количество принимаемых пакетов в секунду */ struct Stats
size_t statUpPerSec = { 0 }; /*!< количество обработанных пакетов в секунду */ {
float recvPerSec = {0}; /*!< количество принимаемых пакетов в секунду */
float upPerSec = {0}; /*!< количество обработанных пакетов в секунду */
size_t upProcessingTime_microsec = {0}; /*!< время обработки данных */
size_t recvProcessingTime_microsec = {0}; /*!< время обработки получения данных */
};
Stats stats;
// делаем loop общим.. одним на всех! // делаем loop общим.. одним на всех!
static CommonEventLoop loop; static CommonEventLoop loop;
......
...@@ -30,8 +30,8 @@ int main(int argc, char* argv[] ) ...@@ -30,8 +30,8 @@ int main(int argc, char* argv[] )
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
// if( returnCode != 0 ) // Indicates a command line error // if( returnCode != 0 ) // Indicates a command line error
// return returnCode; // return returnCode;
uniset_init(argc, argv); uniset_init(argc, argv);
......
...@@ -30,8 +30,8 @@ int main(int argc, const char* argv[] ) ...@@ -30,8 +30,8 @@ int main(int argc, const char* argv[] )
int returnCode = session.applyCommandLine( argc, argv ); int returnCode = session.applyCommandLine( argc, argv );
// if( returnCode != 0 ) // Indicates a command line error // if( returnCode != 0 ) // Indicates a command line error
// return returnCode; // return returnCode;
auto conf = uniset_init(argc, argv); auto conf = uniset_init(argc, argv);
......
...@@ -30,8 +30,8 @@ int main(int argc, const char* argv[] ) ...@@ -30,8 +30,8 @@ int main(int argc, const char* argv[] )
int returnCode = session.applyCommandLine( argc, argv ); int returnCode = session.applyCommandLine( argc, argv );
// if( returnCode != 0 ) // Indicates a command line error // if( returnCode != 0 ) // Indicates a command line error
// return returnCode; // return returnCode;
auto conf = uniset_init(argc, argv); auto conf = uniset_init(argc, argv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment