| 205 | } |
| 206 | |
| 207 | void SystemStateInfo::ComputeNetworkUsage(int64_t period_ms) { |
| 208 | if (period_ms <= 0) return; |
| 209 | // Compute network throughput in bytes per second |
| 210 | const NetworkValues& cur = network_values_[net_val_idx_]; |
| 211 | const NetworkValues& old = network_values_[1 - net_val_idx_]; |
| 212 | int64_t rx_bytes = cur[NET_RX_BYTES] - old[NET_RX_BYTES]; |
| 213 | network_usage_.rx_rate.Store(rx_bytes * 1000L / period_ms); |
| 214 | |
| 215 | int64_t tx_bytes = cur[NET_TX_BYTES] - old[NET_TX_BYTES]; |
| 216 | network_usage_.tx_rate.Store(tx_bytes * 1000L / period_ms); |
| 217 | } |
| 218 | |
| 219 | void SystemStateInfo::ReadCurrentProcDiskStats() { |
| 220 | string path = "/proc/diskstats"; |