summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-09-25 20:58:10 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-09-25 20:58:10 -0400
commitcfbd6b4b994f58997c0ee1b44ff9325648ecf660 (patch)
treea77386ce21f0ce6c51cecc3e82ff770ee0fdee96
parentb1e98d106d4f5156b544224ff23ca062442f70b3 (diff)
downloadgtk+-cfbd6b4b994f58997c0ee1b44ff9325648ecf660.tar.gz
gsk: Add a way to reset profiler counters
It is often useful to count things per-frame, and reset the counter afterwards.
-rw-r--r--gsk/gskprofiler.c26
-rw-r--r--gsk/gskprofilerprivate.h3
2 files changed, 28 insertions, 1 deletions
diff --git a/gsk/gskprofiler.c b/gsk/gskprofiler.c
index bc7301046b..be83d66a56 100644
--- a/gsk/gskprofiler.c
+++ b/gsk/gskprofiler.c
@@ -207,6 +207,26 @@ gsk_profiler_counter_inc (GskProfiler *profiler,
}
void
+gsk_profiler_counter_set (GskProfiler *profiler,
+ GQuark counter_id,
+ gint64 value)
+{
+ NamedCounter *counter;
+
+ g_return_if_fail (GSK_IS_PROFILER (profiler));
+
+ counter = gsk_profiler_get_counter (profiler, counter_id);
+ if (counter == NULL)
+ {
+ g_critical ("No counter '%s' (id:%d) found; did you forget to call gsk_profiler_add_counter()?",
+ g_quark_to_string (counter_id), counter_id);
+ return;
+ }
+
+ counter->value = value;
+}
+
+void
gsk_profiler_counter_add (GskProfiler *profiler,
GQuark counter_id,
gint64 increment)
@@ -217,7 +237,11 @@ gsk_profiler_counter_add (GskProfiler *profiler,
counter = gsk_profiler_get_counter (profiler, counter_id);
if (counter == NULL)
- return;
+ {
+ g_critical ("No counter '%s' (id:%d) found; did you forget to call gsk_profiler_add_counter()?",
+ g_quark_to_string (counter_id), counter_id);
+ return;
+ }
counter->value += increment;
}
diff --git a/gsk/gskprofilerprivate.h b/gsk/gskprofilerprivate.h
index e30a810432..ca0f44518b 100644
--- a/gsk/gskprofilerprivate.h
+++ b/gsk/gskprofilerprivate.h
@@ -25,6 +25,9 @@ void gsk_profiler_counter_inc (GskProfiler *profiler,
void gsk_profiler_counter_add (GskProfiler *profiler,
GQuark counter_id,
gint64 increment);
+void gsk_profiler_counter_set (GskProfiler *profiler,
+ GQuark counter_id,
+ gint64 value);
void gsk_profiler_timer_begin (GskProfiler *profiler,
GQuark timer_id);
gint64 gsk_profiler_timer_end (GskProfiler *profiler,