@@ -315,6 +315,7 @@ struct KnownCounters
315315 const char * name;
316316 unsigned type;
317317 unsigned code;
318+ unsigned scope = 0 ;
318319};
319320
320321#define TOTAL_COUNTERS 11
@@ -324,12 +325,12 @@ constexpr KnownCounters knownCounters[TOTAL_COUNTERS] = {
324325 {" RealTime" , CNT_TIMER , CNT_TIME_REAL },
325326 {" UserTime" , CNT_TIMER , CNT_TIME_USER },
326327 {" SystemTime" , CNT_TIMER , CNT_TIME_SYSTEM },
327- {" Fetches" , CNT_DB_INFO , isc_info_fetches},
328- {" Marks" , CNT_DB_INFO , isc_info_marks},
329- {" Reads" , CNT_DB_INFO , isc_info_reads},
330- {" Writes" , CNT_DB_INFO , isc_info_writes},
331- {" CurrentMemory" , CNT_DB_INFO , isc_info_current_memory},
332- {" MaxMemory" , CNT_DB_INFO , isc_info_max_memory},
328+ {" Fetches" , CNT_DB_INFO , isc_info_fetches, fb_info_counts_scope_att },
329+ {" Marks" , CNT_DB_INFO , isc_info_marks, fb_info_counts_scope_att },
330+ {" Reads" , CNT_DB_INFO , isc_info_reads, fb_info_counts_scope_att },
331+ {" Writes" , CNT_DB_INFO , isc_info_writes, fb_info_counts_scope_att },
332+ {" CurrentMemory" , CNT_DB_INFO , isc_info_current_memory, fb_info_counts_scope_db },
333+ {" MaxMemory" , CNT_DB_INFO , isc_info_max_memory, fb_info_counts_scope_db },
333334 {" Buffers" , CNT_DB_INFO , isc_info_num_buffers},
334335 {" PageSize" , CNT_DB_INFO , isc_info_page_size}
335336};
@@ -350,8 +351,10 @@ void Why::UtilInterface::getPerfCounters(Firebird::CheckStatusWrapper* status,
350351 constexpr const char * delim = " \t ,;" ;
351352 unsigned typeMask = 0 ;
352353 unsigned n = 0 ;
353- UCHAR info[TOTAL_COUNTERS ]; // will never use all, but do not care about few bytes
354+ // We multiply by two because tags are in random order and we need to store their scope before process
355+ UCHAR info[TOTAL_COUNTERS * 2 ]; // will never use all, but do not care about few bytes
354356 UCHAR * pinfo = info;
357+ unsigned lastScope = 0 ;
355358
356359#ifdef WIN_NT
357360#define strtok_r strtok_s
@@ -372,7 +375,14 @@ void Why::UtilInterface::getPerfCounters(Firebird::CheckStatusWrapper* status,
372375 typeMask |= knownCounters[i].type ;
373376
374377 if (knownCounters[i].type == CNT_DB_INFO )
375- *pinfo++ = knownCounters[i].code ;
378+ {
379+ const UCHAR tag = knownCounters[i].code ;
380+ const unsigned scope = knownCounters[i].scope ;
381+
382+ if (scope && lastScope != scope) *pinfo++ = lastScope = scope;
383+
384+ *pinfo++ = tag;
385+ }
376386
377387 goto found;
378388 }
@@ -442,6 +452,10 @@ found: ;
442452
443453 switch (ipb)
444454 {
455+ case fb_info_counts_scope_att:
456+ case fb_info_counts_scope_db:
457+ continue ;
458+
445459 case isc_info_reads:
446460 case isc_info_writes:
447461 case isc_info_marks:
0 commit comments