mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
[Network] Measure real server round-trip times (#7153)
* [Network] Measure real server round-trip times Time each command container from send to response with QElapsedTimer, aggregate samples in a fixed-size ring buffer (last/median/p95/max), and emit aggregated pingStatsUpdated at most once per second so the hot path stays free of signal traffic. Stats are cleared on disconnect. Forward the signal through ConnectionController for UI consumers. Unit-tested in latency_tracker_test. Took 37 minutes Took 4 minutes # Commit time for manual adjustment: # Took 8 minutes * Move params to struct, more informative debug Took 56 seconds Took 53 seconds Took 2 minutes Took 33 seconds --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
157e7022cd
commit
b91e872f5f
12 changed files with 389 additions and 2 deletions
|
|
@ -29,3 +29,13 @@ int PendingCommand::tick()
|
|||
{
|
||||
return ++ticks;
|
||||
}
|
||||
|
||||
void PendingCommand::startTiming()
|
||||
{
|
||||
startTime.start();
|
||||
}
|
||||
|
||||
qint64 PendingCommand::elapsedMs() const
|
||||
{
|
||||
return startTime.isValid() ? startTime.nsecsElapsed() / 1000000 : -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef PENDING_COMMAND_H
|
||||
#define PENDING_COMMAND_H
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QVariant>
|
||||
#include <libcockatrice/protocol/pb/commands.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
|
|
@ -21,6 +22,7 @@ private:
|
|||
CommandContainer commandContainer;
|
||||
QVariant extraData;
|
||||
int ticks;
|
||||
QElapsedTimer startTime;
|
||||
|
||||
public:
|
||||
explicit PendingCommand(const CommandContainer &_commandContainer, QVariant _extraData = QVariant());
|
||||
|
|
@ -29,6 +31,18 @@ public:
|
|||
QVariant getExtraData() const;
|
||||
void processResponse(const Response &response);
|
||||
int tick();
|
||||
|
||||
/**
|
||||
* @brief Starts the round-trip timer. Called by the client thread right
|
||||
* before the command container is handed to the transport layer.
|
||||
*/
|
||||
void startTiming();
|
||||
|
||||
/**
|
||||
* @return Milliseconds elapsed since startTiming(), or -1 if the timer was
|
||||
* never started.
|
||||
*/
|
||||
qint64 elapsedMs() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue