LCOV - code coverage report
Current view: top level - gjs - profiler-private.h (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 77.8 % 9 7
Test Date: 2025-02-15 06:20:10 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 50.0 % 4 2

             Branch data     Line data    Source code
       1                 :             : /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
       2                 :             : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
       3                 :             : // SPDX-FileCopyrightText: 2018 Endless Mobile, Inc.
       4                 :             : 
       5                 :             : #ifndef GJS_PROFILER_PRIVATE_H_
       6                 :             : #define GJS_PROFILER_PRIVATE_H_
       7                 :             : 
       8                 :             : #include <config.h>
       9                 :             : 
      10                 :             : #include <stdint.h>
      11                 :             : #include <string>
      12                 :             : 
      13                 :             : #include <js/GCAPI.h>  // for JSFinalizeStatus, JSGCStatus, GCReason
      14                 :             : #include <js/ProfilingCategory.h>
      15                 :             : #include <js/ProfilingStack.h>
      16                 :             : #include <js/RootingAPI.h>
      17                 :             : #include <js/TypeDecls.h>
      18                 :             : 
      19                 :             : #include "gjs/context.h"
      20                 :             : #include "gjs/profiler.h"
      21                 :             : 
      22                 :             : #define GJS_PROFILER_DYNAMIC_STRING(cx, str) \
      23                 :             :     js::GetContextProfilingStackIfEnabled(cx) ? str : ""
      24                 :             : 
      25                 :             : class AutoProfilerLabel {
      26                 :             :  public:
      27                 :       79008 :     explicit inline AutoProfilerLabel(JSContext* cx, const char* label,
      28                 :             :                                       const std::string& dynamicString,
      29                 :             :                                       JS::ProfilingCategoryPair categoryPair =
      30                 :             :                                           JS::ProfilingCategoryPair::OTHER,
      31                 :             :                                       uint32_t flags = 0)
      32                 :       79008 :         : m_stack(js::GetContextProfilingStackIfEnabled(cx)) {
      33         [ -  + ]:       79008 :         if (m_stack)
      34                 :           0 :             m_stack->pushLabelFrame(label, dynamicString.c_str(), this,
      35                 :             :                                     categoryPair, flags);
      36                 :       79008 :     }
      37                 :             : 
      38                 :       79005 :     inline ~AutoProfilerLabel() {
      39         [ -  + ]:       79005 :         if (m_stack)
      40                 :           0 :             m_stack->pop();
      41                 :       79005 :     }
      42                 :             : 
      43                 :             :  private:
      44                 :             :     ProfilingStack* m_stack;
      45                 :             : };
      46                 :             : 
      47                 :             : namespace Gjs {
      48                 :             : enum GCCounters { GC_HEAP_BYTES, MALLOC_HEAP_BYTES, N_COUNTERS };
      49                 :             : }  // namespace Gjs
      50                 :             : 
      51                 :             : GjsProfiler *_gjs_profiler_new(GjsContext *context);
      52                 :             : void _gjs_profiler_free(GjsProfiler *self);
      53                 :             : 
      54                 :             : void _gjs_profiler_add_mark(GjsProfiler* self, int64_t time, int64_t duration,
      55                 :             :                             const char* group, const char* name,
      56                 :             :                             const char* message);
      57                 :             : 
      58                 :             : [[nodiscard]] bool _gjs_profiler_sample_gc_memory_info(
      59                 :             :     GjsProfiler* self, int64_t gc_counters[Gjs::GCCounters::N_COUNTERS]);
      60                 :             : 
      61                 :             : [[nodiscard]] bool _gjs_profiler_is_running(GjsProfiler* self);
      62                 :             : 
      63                 :             : void _gjs_profiler_setup_signals(GjsProfiler *self, GjsContext *context);
      64                 :             : 
      65                 :             : void _gjs_profiler_set_finalize_status(GjsProfiler*, JSFinalizeStatus);
      66                 :             : void _gjs_profiler_set_gc_status(GjsProfiler*, JSGCStatus, JS::GCReason);
      67                 :             : 
      68                 :             : #endif  // GJS_PROFILER_PRIVATE_H_
        

Generated by: LCOV version 2.0-1