LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/io - io_utils.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 40 42 95.2 %
Date: 2026-09-07 02:14:47 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
       3             : //
       4             : 
       5             : #include <sandesh/sandesh_trace.h>
       6             : 
       7             : #include "base/util.h"
       8             : #include "io/io_types.h"
       9             : #include "io/io_utils.h"
      10             : 
      11             : namespace io {
      12             : 
      13       47530 : SocketStats::SocketStats() {
      14       47530 :     read_calls = 0;
      15       47526 :     read_bytes = 0;
      16       47527 :     read_errors = 0;
      17       47530 :     write_calls = 0;
      18       47526 :     write_bytes = 0;
      19       47528 :     write_errors = 0;
      20       47530 :     write_block_start_time = 0;
      21       47530 :     write_blocked = 0;
      22       47528 :     write_blocked_duration_usecs = 0;
      23       47530 :     read_block_start_time = 0;
      24       47529 :     read_blocked = 0;
      25       47529 :     read_blocked_duration_usecs = 0;
      26       47525 : }
      27             : 
      28         669 : void SocketStats::GetRxStats(SocketIOStats *socket_stats) const {
      29         669 :     socket_stats->calls = read_calls;
      30         669 :     socket_stats->bytes = read_bytes;
      31         669 :     if (read_calls) {
      32         259 :         socket_stats->average_bytes =
      33         259 :             static_cast<double>(read_bytes / read_calls);
      34             :     }
      35         669 :     socket_stats->blocked_count = read_blocked;
      36        1338 :     socket_stats->blocked_duration = duration_usecs_to_string(
      37         669 :         read_blocked_duration_usecs);
      38         669 :     if (read_blocked) {
      39             :         socket_stats->average_blocked_duration =
      40           4 :                  duration_usecs_to_string(
      41             :                      read_blocked_duration_usecs/
      42           4 :                      read_blocked);
      43             :     }
      44         669 :     socket_stats->errors = read_errors;
      45         669 : }
      46             : 
      47         666 : void SocketStats::GetTxStats(SocketIOStats *socket_stats) const {
      48         666 :     socket_stats->calls = write_calls;
      49         666 :     socket_stats->bytes = write_bytes;
      50         666 :     if (write_calls) {
      51         256 :         socket_stats->average_bytes =
      52         256 :             static_cast<double>(write_bytes / write_calls);
      53             :     }
      54         666 :     socket_stats->blocked_count = write_blocked;
      55        1332 :     socket_stats->blocked_duration = duration_usecs_to_string(
      56         666 :         write_blocked_duration_usecs);
      57         666 :     if (write_blocked) {
      58             :         socket_stats->average_blocked_duration =
      59           0 :                  duration_usecs_to_string(
      60             :                      write_blocked_duration_usecs/
      61           0 :                      write_blocked);
      62             :     }
      63         666 :     socket_stats->errors = write_errors;
      64         666 : }
      65             : 
      66             : }  // namespace io

Generated by: LCOV version 1.14