[PATCH] traceeval: Add way to extract the number of elements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

Add traceeval_count() that will return the number of elements in the
traceeval. This can be useful for allocating an array to store the
elements. By getting the count, the allocation can be done first and
then iterated to load the elements into the array.

Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 include/traceeval-hist.h |  2 ++
 src/histograms.c         | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/traceeval-hist.h b/include/traceeval-hist.h
index eefa48d..44d071f 100644
--- a/include/traceeval-hist.h
+++ b/include/traceeval-hist.h
@@ -204,6 +204,8 @@ int traceeval_query_size(struct traceeval *teval, const struct traceeval_data *k
 void traceeval_results_release(struct traceeval *teval,
 			       const struct traceeval_data *results);
 
+size_t traceeval_count(struct traceeval *teval);
+
 #define traceeval_stat(teval, keys, type)				\
 	traceeval_stat_size(teval, keys, TRACEEVAL_ARRAY_SIZE(keys), type)
 
diff --git a/src/histograms.c b/src/histograms.c
index 2456342..ac3f7f7 100644
--- a/src/histograms.c
+++ b/src/histograms.c
@@ -1006,6 +1006,17 @@ int traceeval_remove_size(struct traceeval *teval,
 	return 1;
 }
 
+/**
+ * traceeval_count - Return the number of elements in the traceeval
+ * @teval: The traceeval handle to get the count from
+ *
+ * Returns the number of elements stored by unique keys in the @teval.
+ */
+size_t traceeval_count(struct traceeval *teval)
+{
+	return teval->update_counter;
+}
+
 /**
  * traceeval_iterator_put - release a given iterator
  * @iter: The iterartor to release
-- 
2.40.1





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux