Line data Source code
1 1 : /** 2 : * @file log/stats.h 3 : * 4 : * @brief Statistics module 5 : * 6 : * All the facilities to collect, gather, and dump statistics are implemented 7 : * in this module. 8 : * 9 : * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com> 10 : * SPDX-License-Identifier: GPL-3.0-only 11 : */ 12 : #pragma once 13 : 14 : #include <core/core.h> 15 : 16 0 : enum stats_global_time { 17 : STATS_GLOBAL_INIT_END, 18 : STATS_GLOBAL_EVENTS_START, 19 : STATS_GLOBAL_EVENTS_END, 20 : STATS_GLOBAL_FINI_START, 21 : STATS_GLOBAL_COUNT 22 : }; 23 : 24 0 : enum stats_time { 25 : STATS_MSG_PROCESSED, 26 : STATS_GVT, 27 : STATS_ROLLBACK, 28 : STATS_MSG_SILENT, 29 : STATS_COUNT 30 : }; 31 : 32 : /// A set of statistical values of a single metric 33 : /** The form of these values is designed for easier incremental updates */ 34 1 : struct stats_measure { 35 : /// The count of events of this type 36 1 : uint64_t count; 37 : /// The mean time to complete an event multiplied by the events count 38 1 : uint64_t sum_t; 39 : /// The variance of the time to complete multiplied by the events count 40 1 : uint64_t var_t; 41 : }; 42 : 43 1 : extern void stats_global_time_start(void); 44 1 : extern void stats_global_time_take(enum stats_global_time this_stat); 45 : 46 1 : extern void stats_global_init(void); 47 1 : extern void stats_global_fini(void); 48 1 : extern void stats_init(void); 49 : 50 0 : extern void stats_time_start(enum stats_time this_stat); 51 0 : extern const struct stats_measure *stats_time_query(enum stats_time this_stat); 52 0 : extern void stats_time_take(enum stats_time this_stat); 53 0 : extern void stats_on_gvt(simtime_t current_gvt); 54 0 : extern void stats_dump(void);