summaryrefslogtreecommitdiff
path: root/src/Stats.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-11-24 21:14:38 +0100
committerMax Kellermann <max@duempel.org>2013-11-24 21:14:38 +0100
commit529b4bd185eb130580c09c24450d80d62c9ae769 (patch)
treea002854fefe89cb1eaa16ac0b45558e6ea20478f /src/Stats.cxx
parent85b51e4e779360a4f2ead4404bf4d6b547f6d49d (diff)
Stats: use monotonic clock instead of GTimer
Reduce GLib usage.
Diffstat (limited to 'src/Stats.cxx')
-rw-r--r--src/Stats.cxx19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/Stats.cxx b/src/Stats.cxx
index a188d88ba..e22f1a995 100644
--- a/src/Stats.cxx
+++ b/src/Stats.cxx
@@ -30,9 +30,11 @@
#include "Log.hxx"
#ifndef WIN32
-#include <glib.h>
-
-static GTimer *uptime;
+/**
+ * The monotonic time stamp when MPD was started. It is used to
+ * calculate the uptime.
+ */
+static unsigned start_time;
#endif
static DatabaseStats stats;
@@ -40,14 +42,7 @@ static DatabaseStats stats;
void stats_global_init(void)
{
#ifndef WIN32
- uptime = g_timer_new();
-#endif
-}
-
-void stats_global_finish(void)
-{
-#ifndef WIN32
- g_timer_destroy(uptime);
+ start_time = MonotonicClockS();
#endif
}
@@ -107,7 +102,7 @@ stats_print(Client &client)
#ifdef WIN32
GetProcessUptimeS(),
#else
- (unsigned)g_timer_elapsed(uptime, NULL),
+ MonotonicClockS() - start_time,
#endif
(unsigned long)(client.player_control.GetTotalPlayTime() + 0.5));