coding style - statistics
Hal Murray
hmurray at megapathdsl.net
Sun Aug 30 21:52:47 UTC 2020
Context is that James is working on making ntpq/sysstats (and friends) print out the totals for counters as a second column next to the since-reset that it currently prints. The current counters get reset if/when they are logged hourly so ntpq can't see the big picture after the system has been up for a while.
Currently, we have a blizzard of things like:
extern uint64_t stat_received(void);
and
uint64_t stat_received(void)
{
return stat_count.sys_received;
}
I know that's the "right" way to do it, but it seems like a lot of unnecessary clutter to me.
It took me a while to figure out why I think that way. A procedure would be the clean way to access a simple variable if that was a public API that we expected to support for many clients and a long time. Doubly so if the data is in a struct. But we don't have any external clients and we rebuild everything when we change the struct.
To me, the clutter isn't worth it. Each slot is only used in a few places. The clutter adds 2 more.
Does anybody have strong opinions? (I can live with the clutter, it's just not the way I would do it.)
----------
I'm thinking of making a new header and module: ntp_stats.
The idea is to collect the structs that hold the counters, the code that does the logging and resets, and the new code that merges the about-to-be-reset counters into a second struct.
If people think the procedures are the way to go, I'll have to add one to bump each counter.
--
These are my opinions. I hate spam.
More information about the devel
mailing list