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-08-24 02:06:43 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       48489 : SocketStats::SocketStats() {
      14       48489 :     read_calls = 0;
      15       48488 :     read_bytes = 0;
      16       48490 :     read_errors = 0;
      17       48491 :     write_calls = 0;
      18       48490 :     write_bytes = 0;
      19       48490 :     write_errors = 0;
      20       48490 :     write_block_start_time = 0;
      21       48489 :     write_blocked = 0;
      22       48489 :     write_blocked_duration_usecs = 0;
      23       48490 :     read_block_start_time = 0;
      24       48492 :     read_blocked = 0;
      25       48490 :     read_blocked_duration_usecs = 0;
      26       48490 : }
      27             : 
      28         685 : void SocketStats::GetRxStats(SocketIOStats *socket_stats) const {
      29         685 :     socket_stats->calls = read_calls;
      30         685 :     socket_stats->bytes = read_bytes;
      31         685 :     if (read_calls) {
      32         265 :         socket_stats->average_bytes =
      33         265 :             static_cast<double>(read_bytes / read_calls);
      34             :     }
      35         685 :     socket_stats->blocked_count = read_blocked;
      36        1370 :     socket_stats->blocked_duration = duration_usecs_to_string(
      37         685 :         read_blocked_duration_usecs);
      38         685 :     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         685 :     socket_stats->errors = read_errors;
      45         685 : }
      46             : 
      47         682 : void SocketStats::GetTxStats(SocketIOStats *socket_stats) const {
      48         682 :     socket_stats->calls = write_calls;
      49         682 :     socket_stats->bytes = write_bytes;
      50         682 :     if (write_calls) {
      51         262 :         socket_stats->average_bytes =
      52         262 :             static_cast<double>(write_bytes / write_calls);
      53             :     }
      54         682 :     socket_stats->blocked_count = write_blocked;
      55        1364 :     socket_stats->blocked_duration = duration_usecs_to_string(
      56         682 :         write_blocked_duration_usecs);
      57         682 :     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         682 :     socket_stats->errors = write_errors;
      64         682 : }
      65             : 
      66             : }  // namespace io

Generated by: LCOV version 1.14