Stats: use monotonic clock instead of GTimer

Reduce GLib usage.
This commit is contained in:
Max Kellermann
2013-11-24 21:14:38 +01:00
parent 85b51e4e77
commit 529b4bd185
5 changed files with 36 additions and 15 deletions

View File

@@ -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));