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-08-06 15:29:52 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              : 
      15              : namespace {
      16         2600 : bool IsDumpToStdEnabled() {
      17         2600 :    const char *profilingToStdOut = nullptr;
      18         2600 :    MM_SYS_GET_ENV(MM_ENV_GE_PROFILING_TO_STD_OUT, profilingToStdOut);
      19         2600 :    return profilingToStdOut != nullptr;
      20              : }
      21              : }
      22              : 
      23              : namespace acl {
      24              : bool AclProfilingReporter::profRun = false;
      25         1479 : AclProfilingReporter::AclProfilingReporter(const AclProfType apiId) : aclApi_(apiId)
      26              : {
      27         1479 :     if (profRun && (!IsDumpToStdEnabled())) {
      28         1300 :         startTime_ = MsprofSysCycleTime();
      29              :     }
      30         1479 : }
      31              : 
      32              : 
      33         1483 : AclProfilingReporter::~AclProfilingReporter() noexcept
      34              : {
      35         1483 :     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         1483 : }
      48              : }  // namespace acl
        

Generated by: LCOV version 2.0-1