[gtk+] gsk: Redo the sampling in the profiler
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gsk: Redo the sampling in the profiler
- Date: Thu, 28 Sep 2017 14:29:58 +0000 (UTC)
commit 767966933da11b626b9d53510b30179c9b1a41f6
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 28 10:23:12 2017 -0400
gsk: Redo the sampling in the profiler
Reset the min/max/average counters before calculating,
and only print the values if we have samples. In addition,
print the number of samples.
gsk/gskprofiler.c | 36 +++++++++++++++++++++++++-----------
1 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/gsk/gskprofiler.c b/gsk/gskprofiler.c
index be83d66..2a09702 100644
--- a/gsk/gskprofiler.c
+++ b/gsk/gskprofiler.c
@@ -462,6 +462,17 @@ gsk_profiler_append_timers (GskProfiler *profiler,
g_return_if_fail (GSK_IS_PROFILER (profiler));
g_return_if_fail (buffer != NULL);
+ g_hash_table_iter_init (&iter, profiler->timers);
+ while (g_hash_table_iter_next (&iter, NULL, &value_p))
+ {
+ NamedTimer *timer = value_p;
+
+ timer->min_value = G_MAXINT64;
+ timer->max_value = G_MININT64;
+ timer->avg_value = 0;
+ timer->n_samples = 0;
+ }
+
for (i = 0; i < profiler->last_sample; i++)
{
Sample *s = &(profiler->timer_samples[i]);
@@ -484,18 +495,21 @@ gsk_profiler_append_timers (GskProfiler *profiler,
const char *unit = timer->invert ? "" : "usec";
double scale = timer->invert ? 1.0 : 1000.0;
- if (timer->n_samples != 0)
- timer->avg_value = timer->avg_value / timer->n_samples;
-
- g_string_append_printf (buffer,
- "%s %s: "
- "Min:%.2f, "
- "Avg:%.2f, "
- "Max:%.2f\n",
+ g_string_append_printf (buffer, "%s (%s): %.2f",
timer->description,
unit,
- (double) timer->min_value / scale,
- (double) timer->avg_value / scale,
- (double) timer->max_value / scale);
+ (double) timer->value / scale);
+
+ if (timer->n_samples > 1)
+ {
+ timer->avg_value = timer->avg_value / timer->n_samples;
+ g_string_append_printf (buffer, " Min: %.2f Avg: %.2f Max: %.2f (%ld samples)",
+ (double) timer->min_value / scale,
+ (double) timer->avg_value / scale,
+ (double) timer->max_value / scale,
+ timer->n_samples);
+ }
+
+ g_string_append (buffer, "\n");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]