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-10-05 02:12:29 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        4845 : SocketStats::SocketStats() {
      14        4845 :     read_calls = 0;
      15        4846 :     read_bytes = 0;
      16        4846 :     read_errors = 0;
      17        4846 :     write_calls = 0;
      18        4843 :     write_bytes = 0;
      19        4845 :     write_errors = 0;
      20        4846 :     write_block_start_time = 0;
      21        4846 :     write_blocked = 0;
      22        4846 :     write_blocked_duration_usecs = 0;
      23        4846 :     read_block_start_time = 0;
      24        4846 :     read_blocked = 0;
      25        4845 :     read_blocked_duration_usecs = 0;
      26        4844 : }
      27             : 
      28         418 : void SocketStats::GetRxStats(SocketIOStats *socket_stats) const {
      29         418 :     socket_stats->calls = read_calls;
      30         418 :     socket_stats->bytes = read_bytes;
      31         418 :     if (read_calls) {
      32         198 :         socket_stats->average_bytes =
      33         198 :             static_cast<double>(read_bytes / read_calls);
      34             :     }
      35         418 :     socket_stats->blocked_count = read_blocked;
      36         836 :     socket_stats->blocked_duration = duration_usecs_to_string(
      37         418 :         read_blocked_duration_usecs);
      38         418 :     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         418 :     socket_stats->errors = read_errors;
      45         418 : }
      46             : 
      47         415 : void SocketStats::GetTxStats(SocketIOStats *socket_stats) const {
      48         415 :     socket_stats->calls = write_calls;
      49         415 :     socket_stats->bytes = write_bytes;
      50         415 :     if (write_calls) {
      51         195 :         socket_stats->average_bytes =
      52         195 :             static_cast<double>(write_bytes / write_calls);
      53             :     }
      54         415 :     socket_stats->blocked_count = write_blocked;
      55         830 :     socket_stats->blocked_duration = duration_usecs_to_string(
      56         415 :         write_blocked_duration_usecs);
      57         415 :     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         415 :     socket_stats->errors = write_errors;
      64         415 : }
      65             : 
      66             : }  // namespace io

Generated by: LCOV version 1.14