summaryrefslogtreecommitdiffstats
path: root/src/statistics.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-26 14:39:08 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-29 01:10:06 +0100
commit80db4ec3875b0de7f06de769881d6c5d4b713f2d (patch)
tree8fc6dfe6d2e035491a11b8c2e1ccb2a815f93d7c /src/statistics.c
parentc27671c10935ee384d03a87170c3f31ab435da07 (diff)
core: Add difference function to osmo_counter
The osmo_counter_difference returns the counter value difference since the last call of this function with the given counter object. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/statistics.c')
-rw-r--r--src/statistics.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/statistics.c b/src/statistics.c
index e28541ba..ad069cea 100644
--- a/src/statistics.c
+++ b/src/statistics.c
@@ -74,3 +74,11 @@ struct osmo_counter *osmo_counter_get_by_name(const char *name)
}
return NULL;
}
+
+int osmo_counter_difference(struct osmo_counter *ctr)
+{
+ int delta = ctr->value - ctr->previous;
+ ctr->previous = ctr->value;
+
+ return delta;
+}