QoL Changes

fix timetrace last diff
This commit is contained in:
2025-12-27 23:35:23 +01:00
parent 03f65e069f
commit 7fc7a2ecb9
5 changed files with 31 additions and 16 deletions

View File

@@ -30,7 +30,7 @@ namespace PD {
* Class to calculate Maximum/Minimum and Average Timings
*/
class TimeStats {
public:
public:
/**
* Constructor taking a lengh for the List
* @param l Lengh of the data list
@@ -55,8 +55,7 @@ public:
* @return Average
*/
u64 GetAverage() {
if (!num_val)
return 0.f;
if (!num_val) return 0.f;
u64 res = 0;
for (int i = 0; i < num_val; i++) {
res += val[smart_idx(i)];
@@ -69,8 +68,7 @@ public:
* @return Minimum value
*/
u64 GetMin() {
if (!num_val)
return 0.f;
if (!num_val) return 0.f;
u64 res = std::numeric_limits<u64>::max();
for (int i = 0; i < num_val; i++) {
res = std::min(val[smart_idx(i)], res);
@@ -83,8 +81,7 @@ public:
* @return Max Value
*/
u64 GetMax() {
if (!num_val)
return 0.f;
if (!num_val) return 0.f;
u64 res = 0;
for (int i = 0; i < num_val; i++) {
res = std::max(val[smart_idx(i)], res);
@@ -122,7 +119,7 @@ public:
*/
const size_t GetNumValues() { return num_val; }
private:
private:
/**
* Get the Next Position to write to
* @param c current position
@@ -152,7 +149,7 @@ namespace TT {
* Data Structure for a TimeTrace Result
*/
class Res {
public:
public:
/** Constructore that Inits a protocol at size of 60 frames */
Res() : start(0), end(0) { protocol = TimeStats::New(60); }
~Res() = default;
@@ -185,6 +182,7 @@ public:
*/
void SetEnd(u64 v) {
end = v;
diff = end - start;
protocol->Add(GetLastDiff());
}
/**
@@ -197,20 +195,22 @@ public:
* Get Last Diffrence between end and start
* @return end - start
*/
u64 GetLastDiff() { return end - start; }
u64 GetLastDiff() { return diff; }
/**
* Get Protcol Reference
* @return Protocol Ref
*/
TimeStats::Ref GetProtocol() { return protocol; }
private:
private:
/** Trace ID */
std::string id;
/** Start time */
u64 start;
/** End Time */
u64 end;
/** Last Diff */
u64 diff;
/** Protocol */
TimeStats::Ref protocol;
};
@@ -240,7 +240,7 @@ PD_CORE_API void End(const std::string &id);
* ```
*/
class Scope {
public:
public:
/**
* Constructor requiring a Name for the Trace
* @param id Name of the Trace
@@ -254,9 +254,9 @@ public:
*/
~Scope() { End(ID); }
private:
private:
/** Trace Name/ID */
std::string ID;
};
} // namespace TT
} // namespace PD
} // namespace TT
} // namespace PD