2022-12-06 22:53:37 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: AuSocketStats.cpp
|
|
|
|
Date: 2022-12-06
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include "Networking.hpp"
|
|
|
|
#include "AuSocketStats.hpp"
|
|
|
|
|
|
|
|
namespace Aurora::IO::Net
|
|
|
|
{
|
|
|
|
void SocketStats::AddBytes(AuUInt32 uBytes)
|
|
|
|
{
|
2023-10-23 08:04:36 +00:00
|
|
|
this->Start();
|
2022-12-06 22:53:37 +00:00
|
|
|
this->calculator.AddData(uBytes);
|
2024-10-19 16:47:05 +00:00
|
|
|
this->uLastTimeSteadyMS = AuTime::SteadyClockMS();
|
2022-12-06 22:53:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AuInt64 SocketStats::GetFirstTickTimeMS()
|
|
|
|
{
|
2023-10-23 08:04:36 +00:00
|
|
|
return this->uFirstTime;
|
2022-12-06 22:53:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AuInt64 SocketStats::GetLastTickTimeMS()
|
|
|
|
{
|
2023-10-23 08:04:36 +00:00
|
|
|
return this->calculator.GetLastFrameTimeWall();
|
2022-12-06 22:53:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AuUInt64 SocketStats::GetTotalBytesTransferred()
|
|
|
|
{
|
|
|
|
return this->calculator.GetTotalStats();
|
|
|
|
}
|
|
|
|
|
|
|
|
double SocketStats::GetApproximatedThroughput()
|
|
|
|
{
|
|
|
|
return this->calculator.GetEstimatedHertz();
|
|
|
|
}
|
2023-10-23 08:04:36 +00:00
|
|
|
|
|
|
|
AuUInt64 SocketStats::GetUptimeNS()
|
|
|
|
{
|
|
|
|
if (auto uStartTime = this->uStartSteadyTime)
|
|
|
|
{
|
|
|
|
if (auto uEndTime = this->uEndSteadyTime)
|
|
|
|
{
|
|
|
|
return uEndTime - uStartTime;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return AuTime::SteadyClockNS() - uStartTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SocketStats::Start()
|
|
|
|
{
|
|
|
|
if (!this->uFirstTime)
|
|
|
|
{
|
|
|
|
this->uFirstTime = AuTime::CurrentClockMS();
|
|
|
|
this->uStartSteadyTime = AuTime::SteadyClockNS();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SocketStats::End()
|
|
|
|
{
|
|
|
|
this->uEndSteadyTime = AuTime::SteadyClockNS();
|
|
|
|
}
|
2022-12-06 22:53:37 +00:00
|
|
|
}
|