Matter SDK Coverage Report
Current view: top level - tracing/esp32_diagnostics - Counter.h (source / functions) Coverage Total Hit
Test: SHA:db08debc068562b264a2df3a7f3a8cc1d0b3aba1 Lines: 0.0 % 5 0
Test Date: 2025-10-02 07:10:30 Functions: 0.0 % 3 0

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2025 Project CHIP Authors
       4              :  *    All rights reserved.
       5              :  *
       6              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       7              :  *    you may not use this file except in compliance with the License.
       8              :  *    You may obtain a copy of the License at
       9              :  *
      10              :  *        http://www.apache.org/licenses/LICENSE-2.0
      11              :  *
      12              :  *    Unless required by applicable law or agreed to in writing, software
      13              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      14              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15              :  *    See the License for the specific language governing permissions and
      16              :  *    limitations under the License.
      17              :  */
      18              : 
      19              : #pragma once
      20              : 
      21              : #include "tracing/esp32_diagnostics/DiagnosticEntry.h"
      22              : #include "tracing/esp32_diagnostics/DiagnosticStorage.h"
      23              : #include <map>
      24              : 
      25              : namespace chip {
      26              : namespace Tracing {
      27              : namespace Diagnostics {
      28              : 
      29              : /**
      30              :  * This class is used to monotonically increment the counters as per the label of the counter macro
      31              :  * 'MATTER_TRACE_COUNTER(label)'
      32              :  * As per the label of the counter macro, it adds the counter in the linked list with the name label if not
      33              :  * present and returns the same instance and increments the value if the counter is already present
      34              :  * in the list.
      35              :  */
      36              : 
      37              : class ESPDiagnosticCounter
      38              : {
      39              : public:
      40            0 :     static ESPDiagnosticCounter & GetInstance()
      41              :     {
      42            0 :         static ESPDiagnosticCounter instance;
      43            0 :         return instance;
      44              :     }
      45              :     static void IncreaseCount(const char * label);
      46              : 
      47              :     uint32_t GetInstanceCount(const char * label) const;
      48              : 
      49              :     CHIP_ERROR ReportMetrics(const char * label, CircularDiagnosticBuffer * storageInstance);
      50              : 
      51              : private:
      52            0 :     ESPDiagnosticCounter() {}
      53              :     // Custom comparator for the map to store the label count
      54              :     struct StringCompare
      55              :     {
      56            0 :         bool operator()(const char * a, const char * b) const { return strcmp(a, b) < 0; }
      57              :     };
      58              :     static std::map<const char *, uint32_t, StringCompare> mCounterList;
      59              : };
      60              : 
      61              : } // namespace Diagnostics
      62              : } // namespace Tracing
      63              : } // namespace chip
        

Generated by: LCOV version 2.0-1