[sysprof] libsysprof-ui: ignore negative and 0 averages
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-ui: ignore negative and 0 averages
- Date: Wed, 29 May 2019 22:32:27 +0000 (UTC)
commit 16780fa765500c7eb9c42e4fbf7abdfab07748dd
Author: Christian Hergert <chergert redhat com>
Date: Fri May 17 09:59:34 2019 -0700
libsysprof-ui: ignore negative and 0 averages
This ensures that we only calculate averages for marks that have a valid
duration. We also need a new field for the number of averages we added
so that we don't skew the results.
src/libsysprof-ui/sysprof-capture-view.c | 11 ++++++++---
src/libsysprof-ui/sysprof-ui-private.h | 1 +
2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c
index 8d2a36d..15e96ac 100644
--- a/src/libsysprof-ui/sysprof-capture-view.c
+++ b/src/libsysprof-ui/sysprof-capture-view.c
@@ -358,7 +358,12 @@ sysprof_capture_view_scan_worker (GTask *task,
if (mark->duration > mstat->max)
mstat->max = mark->duration;
- mstat->avg += mark->duration;
+ if (mark->duration > 0)
+ {
+ mstat->avg += mark->duration;
+ mstat->avg_count++;
+ }
+
mstat->count++;
}
@@ -395,8 +400,8 @@ sysprof_capture_view_scan_worker (GTask *task,
{
SysprofMarkStat *mstat = v;
- if (mstat->count > 0 && mstat->avg > 0)
- mstat->avg /= mstat->count;
+ if (mstat->avg_count > 0 && mstat->avg > 0)
+ mstat->avg /= mstat->avg_count;
#if 0
g_print ("%s: count=%ld avg=%ld min=%ld max=%ld\n",
diff --git a/src/libsysprof-ui/sysprof-ui-private.h b/src/libsysprof-ui/sysprof-ui-private.h
index 99d5bc6..d6982c1 100644
--- a/src/libsysprof-ui/sysprof-ui-private.h
+++ b/src/libsysprof-ui/sysprof-ui-private.h
@@ -32,6 +32,7 @@ typedef struct
gint64 max;
gint64 min;
gint64 avg;
+ guint64 avg_count;
} SysprofMarkStat;
SysprofMarkStat *_sysprof_mark_stat_new (const gchar *name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]