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-03 02:19:58 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       49652 : SocketStats::SocketStats() {
      14       49652 :     read_calls = 0;
      15       49660 :     read_bytes = 0;
      16       49660 :     read_errors = 0;
      17       49661 :     write_calls = 0;
      18       49662 :     write_bytes = 0;
      19       49662 :     write_errors = 0;
      20       49662 :     write_block_start_time = 0;
      21       49661 :     write_blocked = 0;
      22       49659 :     write_blocked_duration_usecs = 0;
      23       49660 :     read_block_start_time = 0;
      24       49662 :     read_blocked = 0;
      25       49662 :     read_blocked_duration_usecs = 0;
      26       49661 : }
      27             : 
      28         678 : void SocketStats::GetRxStats(SocketIOStats *socket_stats) const {
      29         678 :     socket_stats->calls = read_calls;
      30         678 :     socket_stats->bytes = read_bytes;
      31         678 :     if (read_calls) {
      32         255 :         socket_stats->average_bytes =
      33         255 :             static_cast<double>(read_bytes / read_calls);
      34             :     }
      35         678 :     socket_stats->blocked_count = read_blocked;
      36        1356 :     socket_stats->blocked_duration = duration_usecs_to_string(
      37         678 :         read_blocked_duration_usecs);
      38         678 :     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         678 :     socket_stats->errors = read_errors;
      45         678 : }
      46             : 
      47         675 : void SocketStats::GetTxStats(SocketIOStats *socket_stats) const {
      48         675 :     socket_stats->calls = write_calls;
      49         675 :     socket_stats->bytes = write_bytes;
      50         675 :     if (write_calls) {
      51         252 :         socket_stats->average_bytes =
      52         252 :             static_cast<double>(write_bytes / write_calls);
      53             :     }
      54         675 :     socket_stats->blocked_count = write_blocked;
      55        1350 :     socket_stats->blocked_duration = duration_usecs_to_string(
      56         675 :         write_blocked_duration_usecs);
      57         675 :     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         675 :     socket_stats->errors = write_errors;
      64         675 : }
      65             : 
      66             : }  // namespace io

Generated by: LCOV version 1.14