Commit f2a71850 authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

(UNet): added processing statistics

parent 8959f350
......@@ -182,7 +182,7 @@
</RTUExchange>
<UDPExchange name="UDPExchange"/>
<UDPExchange2 name="UDPExchange2"/>
<UNetExchange name="UNetExchange" transport="multicast"/>
<UNetExchange name="UNetExchange" transport1="multicast"/>
<HeartBeatTime msec="5000"/>
<NCReadyTimeout msec="120000"/>
<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
return;
}
statRecvPerSec = recvCount;
statUpPerSec = upCount;
// unetlog9 << myname << "(statisctics):"
// << " recvCount=" << recvCount << "[per sec]"
// << " upCount=" << upCount << "[per sec]"
// << endl;
auto t_end = chrono::high_resolution_clock::now();
float sec = chrono::duration_cast<chrono::duration<float>>(t_end - t_stats).count();
t_stats = t_end;
stats.recvPerSec = recvCount / sec;
stats.upPerSec = upCount / sec;
recvCount = 0;
upCount = 0;
......@@ -485,6 +483,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
return;
bool ok = false;
t_start = chrono::high_resolution_clock::now();
try
{
......@@ -510,6 +509,9 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
std::lock_guard<std::mutex> l(tmMutex);
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()
......@@ -565,6 +567,8 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
bool recvOk = checkConnection();
// обновление данных в SM
t_start = chrono::high_resolution_clock::now();
try
{
update();
......@@ -574,6 +578,9 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
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 )
{
try
......@@ -822,15 +829,20 @@ const std::string UNetReceiver::getShortInfo() const noexcept
<< " lostPackets=" << setw(6) << getLostPacketsNum()
<< endl
<< "\t["
<< " recvTimeout=" << setw(6) << recvTimeout
<< " prepareTime=" << setw(6) << prepareTime
<< " evrunTimeout=" << setw(6) << evrunTimeout
<< " lostTimeout=" << setw(6) << lostTimeout
<< " updatepause=" << setw(6) << updatepause
<< " maxDifferens=" << setw(6) << maxDifferens
<< " recvTimeout=" << recvTimeout
<< " prepareTime=" << prepareTime
<< " evrunTimeout=" << evrunTimeout
<< " lostTimeout=" << lostTimeout
<< " updatepause=" << updatepause
<< " maxDifferens=" << maxDifferens
<< " ]"
<< 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();
}
......
......@@ -209,10 +209,20 @@ namespace uniset
// счётчики для подсчёта статистики
size_t recvCount = { 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 }; /*!< количество принимаемых пакетов в секунду */
size_t statUpPerSec = { 0 }; /*!< количество обработанных пакетов в секунду */
struct Stats
{
float recvPerSec = {0}; /*!< количество принимаемых пакетов в секунду */
float upPerSec = {0}; /*!< количество обработанных пакетов в секунду */
size_t upProcessingTime_microsec = {0}; /*!< время обработки данных */
size_t recvProcessingTime_microsec = {0}; /*!< время обработки получения данных */
};
Stats stats;
// делаем loop общим.. одним на всех!
static CommonEventLoop loop;
......
......@@ -30,8 +30,8 @@ int main(int argc, char* argv[] )
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
// if( returnCode != 0 ) // Indicates a command line error
// return returnCode;
// if( returnCode != 0 ) // Indicates a command line error
// return returnCode;
uniset_init(argc, argv);
......
......@@ -30,8 +30,8 @@ int main(int argc, const char* argv[] )
int returnCode = session.applyCommandLine( argc, argv );
// if( returnCode != 0 ) // Indicates a command line error
// return returnCode;
// if( returnCode != 0 ) // Indicates a command line error
// return returnCode;
auto conf = uniset_init(argc, argv);
......
......@@ -30,8 +30,8 @@ int main(int argc, const char* argv[] )
int returnCode = session.applyCommandLine( argc, argv );
// if( returnCode != 0 ) // Indicates a command line error
// return returnCode;
// if( returnCode != 0 ) // Indicates a command line error
// return returnCode;
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