g_curr_blocks++;
g_curr_bytes += bk->req_szB;
- if (g_curr_bytes > g_max_bytes) {
+
+ // The use of `>=` rather than `>` means that if there are multiple equal
+ // peaks we record the latest one, like `check_for_peak` does.
+ if (g_curr_bytes >= g_max_bytes) {
g_max_blocks = g_curr_blocks;
g_max_bytes = g_curr_bytes;
g_max_instrs = g_curr_instrs;
api->curr_blocks++;
api->curr_bytes += bk->req_szB;
- if (api->curr_bytes > api->max_bytes) {
+
+ // The use of `>=` rather than `>` means that if there are multiple equal
+ // peaks we record the latest one, like `check_for_peak` does.
+ if (api->curr_bytes >= api->max_bytes) {
api->max_blocks = api->curr_blocks;
api->max_bytes = api->curr_bytes;
}
g_curr_blocks += 0; // unchanged
g_curr_bytes += delta;
- if (g_curr_bytes > g_max_bytes) {
+
+ // The use of `>=` rather than `>` means that if there are multiple equal
+ // peaks we record the latest one, like `check_for_peak` does.
+ if (g_curr_bytes >= g_max_bytes) {
g_max_blocks = g_curr_blocks;
g_max_bytes = g_curr_bytes;
g_max_instrs = g_curr_instrs;
api->curr_blocks += 0; // unchanged
api->curr_bytes += delta;
- if (api->curr_bytes > api->max_bytes) {
+
+ // The use of `>=` rather than `>` means that if there are multiple equal
+ // peaks we record the latest one, like `check_for_peak` does.
+ if (api->curr_bytes >= api->max_bytes) {
api->max_blocks = api->curr_blocks;
api->max_bytes = api->curr_bytes;
}