Add "previous" to MVKPerformanceTracker and save value before capturing "latest"

This commit is contained in:
SRSaunders 2024-03-13 09:55:08 -04:00
parent 10400cdaf0
commit 11bd581c8d
2 changed files with 8 additions and 8 deletions

View File

@ -376,6 +376,7 @@ typedef struct {
typedef struct {
uint32_t count; /**< The number of activities of this type. */
double latest; /**< The latest (most recent) value of the activity. */
double previous; /**< The previous (second most recent) value of the activity. */
double average; /**< The average value of the activity. */
double minimum; /**< The minimum value of the activity. */
double maximum; /**< The maximum value of the activity. */
@ -427,10 +428,6 @@ typedef struct {
* than your app was, the size of this structure in your app may be larger or smaller than the
* struct in MoltenVK. See the description of the vkGetPerformanceStatisticsMVK() function for
* information about how to handle this.
*
* TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT
* BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER,
* SHOULD NOT BE CHANGED.
*/
typedef struct {
MVKShaderCompilationPerformance shaderCompilation; /** Shader compilations activities. */

View File

@ -4342,6 +4342,7 @@ void MVKDevice::applyMemoryBarrier(MVKPipelineBarrier& barrier,
void MVKDevice::updateActivityPerformance(MVKPerformanceTracker& activity, double currentValue) {
lock_guard<mutex> lock(_perfLock);
activity.previous = activity.latest;
activity.latest = currentValue;
activity.minimum = ((activity.minimum == 0.0)
? currentValue :
@ -4364,12 +4365,13 @@ void MVKDevice::logActivityInline(MVKPerformanceTracker& activity, MVKPerformanc
}
void MVKDevice::logActivityDuration(MVKPerformanceTracker& activity, MVKPerformanceStatistics& perfStats, bool isInline) {
const char* fmt = (isInline
? "%s performance avg: %.3f ms, latest: %.3f ms, min: %.3f ms, max: %.3f ms, count: %d"
: " %-45s avg: %.3f ms, latest: %.3f ms, min: %.3f ms, max: %.3f ms, count: %d");
? "%s performance avg: %.3f ms, latest: %.3f ms, prev: %.3f ms, min: %.3f ms, max: %.3f ms, count: %d"
: " %-45s avg: %.3f ms, latest: %.3f ms, prev: %.3f ms, min: %.3f ms, max: %.3f ms, count: %d");
MVKLogInfo(fmt,
getActivityPerformanceDescription(activity, perfStats),
activity.average,
activity.latest,
activity.previous,
activity.minimum,
activity.maximum,
activity.count);
@ -4377,12 +4379,13 @@ void MVKDevice::logActivityDuration(MVKPerformanceTracker& activity, MVKPerforma
void MVKDevice::logActivityByteCount(MVKPerformanceTracker& activity, MVKPerformanceStatistics& perfStats, bool isInline) {
const char* fmt = (isInline
? "%s avg: %5llu MB, latest: %5llu MB, min: %5llu MB, max: %5llu MB, count: %d"
: " %-45s avg: %5llu MB, latest: %5llu MB, min: %5llu MB, max: %5llu MB, count: %d");
? "%s avg: %5llu MB, latest: %5llu MB, prev: %5llu MB, min: %5llu MB, max: %5llu MB, count: %d"
: " %-45s avg: %5llu MB, latest: %5llu MB, prev: %5llu MB, min: %5llu MB, max: %5llu MB, count: %d");
MVKLogInfo(fmt,
getActivityPerformanceDescription(activity, perfStats),
uint64_t(activity.average) / KIBI,
uint64_t(activity.latest) / KIBI,
uint64_t(activity.previous) / KIBI,
uint64_t(activity.minimum) / KIBI,
uint64_t(activity.maximum) / KIBI,
activity.count);