LCOV - code coverage report
Current view: top level - acl/common - prof_reporter.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 20 55.0 %
Date: 2026-08-27 13:24:42 Functions: 3 4 75.0 %

          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             : 
      15             : namespace {
      16        1958 : bool IsDumpToStdEnabled() {
      17        1958 :    const char *profilingToStdOut = nullptr;
      18        1958 :    MM_SYS_GET_ENV(MM_ENV_GE_PROFILING_TO_STD_OUT, profilingToStdOut);
      19        1958 :    return profilingToStdOut != nullptr;
      20             : }
      21             : }
      22             : 
      23             : namespace acl {
      24             : bool AclProfilingReporter::profRun = false;
      25        1163 : AclProfilingReporter::AclProfilingReporter(const AclProfType apiId) : aclApi_(apiId)
      26             : {
      27        1163 :     if (profRun && (!IsDumpToStdEnabled())) {
      28         979 :         startTime_ = MsprofSysCycleTime();
      29             :     }
      30        1163 : }
      31             : 
      32             : 
      33        2334 : AclProfilingReporter::~AclProfilingReporter() noexcept
      34             : {
      35        1167 :     if (profRun && (!IsDumpToStdEnabled()) && (startTime_ != 0UL)) {
      36             :         // 1000 ^ 3 converts second to nanosecond
      37           0 :         const uint64_t endTime = MsprofSysCycleTime();
      38           0 :         MsprofApi api{};
      39           0 :         api.beginTime = startTime_;
      40           0 :         api.endTime = endTime;
      41           0 :         thread_local static auto tid = mmGetTid();
      42           0 :         api.threadId = static_cast<uint32_t>(tid);
      43           0 :         api.level = MSPROF_REPORT_ACL_LEVEL;
      44           0 :         api.type = static_cast<uint32_t>(aclApi_);
      45           0 :         (void)MsprofReportApi(true, &api);
      46             :     }
      47        1167 : }
      48             : }  // namespace acl

Generated by: LCOV version 1.14