-
-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stats: Reduce some wasted space for disabled stats.
Unfortunately for now we have the struct itsel,f but it can become mostly empty.
- Loading branch information
Showing
2 changed files
with
48 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright 2020 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2024 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2018 Capitar IT Group BV <[email protected]> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
|
@@ -12,6 +12,8 @@ | |
#define CORE_STATS_H | ||
|
||
#include "core/defs.h" | ||
#include "core/list.h" | ||
#include "core/platform.h" | ||
|
||
// Statistics support. This is inspired in part by the Solaris | ||
// kernel stats framework, but we've simplified and tuned it for our use. | ||
|
@@ -60,6 +62,20 @@ struct nni_stat_info { | |
bool si_alloc : 1; // stat string is allocated | ||
}; | ||
|
||
#ifdef NNG_ENABLE_STATS | ||
#define NNI_STAT_FIELDS(var, ...) \ | ||
static const nni_stat_info var = { __VA_ARGS__ } | ||
#else | ||
#define NNI_STAT_FIELDS(var, ...) static const nni_stat_info var | ||
#endif | ||
|
||
#define NNI_STAT_INFO(var, name, desc, type, unit) \ | ||
NNI_STAT_FIELDS(var, .si_name = name, .si_desc = desc, \ | ||
.si_type = type, .si_unit = unit) | ||
#define NNI_STAT_ATOMIC(var, name, desc, type, unit) \ | ||
NNI_STAT_FIELDS(var, .si_name = name, .si_desc = desc, \ | ||
.si_type = type, .si_unit = unit, .si_atomic = true) | ||
|
||
// nni_stat_add adds a statistic, but the operation is unlocked, and the | ||
// add is to an unregistered stats tree. | ||
void nni_stat_add(nni_stat_item *, nni_stat_item *); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters