Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
85b51e4e
Commit
85b51e4e
authored
Nov 24, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stats: use GetProcessTimes() on WIN32 to determine MPD uptime
Don't use GTimer if the operating system is able to tell us the uptime.
parent
e53a25cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
2 deletions
+51
-2
Stats.cxx
src/Stats.cxx
+14
-2
Clock.cxx
src/system/Clock.cxx
+26
-0
Clock.hxx
src/system/Clock.hxx
+11
-0
No files found.
src/Stats.cxx
View file @
85b51e4e
...
...
@@ -26,21 +26,29 @@
#include "DatabasePlugin.hxx"
#include "DatabaseSimple.hxx"
#include "util/Error.hxx"
#include "system/Clock.hxx"
#include "Log.hxx"
#ifndef WIN32
#include <glib.h>
static
GTimer
*
uptime
;
#endif
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
);
#endif
}
void
stats_update
(
void
)
...
...
@@ -94,9 +102,13 @@ void
stats_print
(
Client
&
client
)
{
client_printf
(
client
,
"uptime: %
l
u
\n
"
"uptime: %u
\n
"
"playtime: %lu
\n
"
,
(
unsigned
long
)
g_timer_elapsed
(
uptime
,
NULL
),
#ifdef WIN32
GetProcessUptimeS
(),
#else
(
unsigned
)
g_timer_elapsed
(
uptime
,
NULL
),
#endif
(
unsigned
long
)(
client
.
player_control
.
GetTotalPlayTime
()
+
0.5
));
if
(
GetDatabase
()
!=
nullptr
)
...
...
src/system/Clock.cxx
View file @
85b51e4e
...
...
@@ -96,3 +96,29 @@ MonotonicClockUS(void)
#endif
}
#ifdef WIN32
gcc_const
static
unsigned
DeltaFileTimeS
(
FILETIME
a
,
FILETIME
b
)
{
ULARGE_INTEGER
a2
,
b2
;
b2
.
LowPart
=
b
.
dwLowDateTime
;
b2
.
HighPart
=
b
.
dwHighDateTime
;
a2
.
LowPart
=
a
.
dwLowDateTime
;
a2
.
HighPart
=
a
.
dwHighDateTime
;
return
(
a2
.
QuadPart
-
b2
.
QuadPart
)
/
10000000
;
}
unsigned
GetProcessUptimeS
()
{
FILETIME
creation_time
,
now
;
GetProcessTimes
(
GetCurrentProcess
(),
&
creation_time
,
nullptr
,
nullptr
,
nullptr
);
GetSystemTimeAsFileTime
(
&
now
);
return
DeltaFileTimeS
(
now
,
creation_time
);
}
#endif
src/system/Clock.hxx
View file @
85b51e4e
...
...
@@ -38,4 +38,15 @@ gcc_pure
uint64_t
MonotonicClockUS
();
#ifdef WIN32
/**
* Returns the uptime of the current process in seconds.
*/
gcc_pure
unsigned
GetProcessUptimeS
();
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment