LCOV - code coverage report
Current view: top level - acl/common - prof_reporter.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 55.0 % 20 11
Test Date: 2026-07-28 10:53:01 Functions: 75.0 % 4 3

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "prof_reporter.h"
      12              : #include "mmpa/mmpa_api.h"
      13              : 
      14              : namespace {
      15         2720 : bool IsDumpToStdEnabled()
      16              : {
      17         2720 :     const char* profilingToStdOut = nullptr;
      18         2720 :     MM_SYS_GET_ENV(MM_ENV_GE_PROFILING_TO_STD_OUT, profilingToStdOut);
      19         2720 :     return profilingToStdOut != nullptr;
      20              : }
      21              : } // namespace
      22              : 
      23              : namespace acl {
      24              : bool AclProfilingReporter::profRun = false;
      25         1548 : AclProfilingReporter::AclProfilingReporter(const AclProfType apiId) : aclApi_(apiId)
      26              : {
      27         1548 :     if (profRun && (!IsDumpToStdEnabled())) {
      28         1360 :         startTime_ = MsprofSysCycleTime();
      29              :     }
      30         1548 : }
      31              : 
      32         1552 : AclProfilingReporter::~AclProfilingReporter() noexcept
      33              : {
      34         1552 :     if (profRun && (!IsDumpToStdEnabled()) && (startTime_ != 0UL)) {
      35              :         // 1000 ^ 3 converts second to nanosecond
      36            0 :         const uint64_t endTime = MsprofSysCycleTime();
      37            0 :         MsprofApi api{};
      38            0 :         api.beginTime = startTime_;
      39            0 :         api.endTime = endTime;
      40            0 :         thread_local static auto tid = mmGetTid();
      41            0 :         api.threadId = static_cast<uint32_t>(tid);
      42            0 :         api.level = MSPROF_REPORT_ACL_LEVEL;
      43            0 :         api.type = static_cast<uint32_t>(aclApi_);
      44            0 :         (void)MsprofReportApi(true, &api);
      45              :     }
      46         1552 : }
      47              : } // namespace acl
        

Generated by: LCOV version 2.0-1