feat: record the peformance of CPU,Network,Latency

The peformance of the CPU is measured by the run time in ms, Network by
the incoming and outgoing bandwith in kB/s and latency is split into
buckets of ping and tiles in ms. The data is stored in seperate CSV
files which will be updated each unit test allowing the peformance data
to be in a form which can be re-used, graphed or at-least monitored in
the future.

Signed-off-by: elliotfreebairn <elliot.freebairn@collabora.com>
Change-Id: I415d414c832a00d2b55815df89f28a2d836a1290
This commit is contained in:
elliotfreebairn 2024-06-28 15:39:05 +01:00 committed by Michael Meeks
parent 5e4e6bddef
commit b1c6ff5c9c
2 changed files with 67 additions and 1 deletions

4
test/.gitignore vendored
View file

@ -14,3 +14,7 @@ gdb.txt
./unithttplib
run_unit.sh
run_unit_standalone.sh
CPU.csv
Network.csv
PingLatency.csv
TileLatency.csv

View file

@ -27,6 +27,10 @@
#include <TraceFile.hpp>
#include <wsd/TileDesc.hpp>
#include <iostream>
#include <fstream>
// store buckets of latency
struct Histogram {
const size_t incLowMs = 10;
@ -81,6 +85,31 @@ struct Histogram {
std::cout << "< " << std::setw(4) << ms << " ms |" << std::string(chrs, '-') << "| " << _buckets[i] << "\n";
}
}
void dumpLatencyToCSV(std::string fileName)
{
std::ofstream file(fileName + "Latency.csv", std::ios::out | std::ios::app);
if (file.tellp() == 0)
{
file << "Total Items,Too Long";
for (size_t i = 0; i < _buckets.size(); ++i) {
size_t bucketUpperLimit = (i < 10) ? (incLowMs * (i + 1)) : (maxLowMs + (i + 1 - 10) * incHighMs);
file << ",<" << bucketUpperLimit << "ms";
}
file << "\n";
}
file << _items << ",";
file << _tooLong << ",";
for(size_t i = 0; i < _buckets.size(); i++)
{
file << _buckets[i] << ",";
}
file << "\n";
}
};
struct Stats {
@ -174,12 +203,45 @@ struct Stats {
" server sent " << Util::getHumanizedBytes(_bytesRecvd) <<
" (" << recvKbps << " kB/s) to " << _connections << " connections.\n";
_pingLatency.dumpLatencyToCSV("Ping");
_tileLatency.dumpLatencyToCSV("Tile");
dumpStressToCSV(runMs);
dumpNetworkStatsToCSV(recvKbps,sentKbps);
std::cout << "we sent:\n";
dumpMap(_sent);
std::cout << "server sent us:\n";
dumpMap(_recvd);
}
void dumpStressToCSV(size_t runMs)
{
std::ofstream file("CPU.csv", std::ios::out | std::ios::app);
if (file.tellp() == 0)
{
file << "Stress (m/s)";
file << "\n";
}
file << runMs << "\n";
}
void dumpNetworkStatsToCSV(size_t recievedKbs, size_t sentKbs)
{
std::ofstream file("Network.csv", std::ios::out | std::ios::app);
if(file.tellp() == 0)
{
file << "Incoming bandwidth (kB/s)" << ",Outgoing bandwidth (kB/s)";
file << "\n";
}
file << recievedKbs << "," << sentKbs << ",";
file << "\n";
}
};
// Avoid a MessageHandler for now.
@ -430,4 +492,4 @@ public:
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */