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
529b4bd1
Commit
529b4bd1
authored
Nov 24, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stats: use monotonic clock instead of GTimer
Reduce GLib usage.
parent
85b51e4e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
15 deletions
+36
-15
Main.cxx
src/Main.cxx
+0
-1
Stats.cxx
src/Stats.cxx
+7
-12
Stats.hxx
src/Stats.hxx
+0
-2
Clock.cxx
src/system/Clock.cxx
+22
-0
Clock.hxx
src/system/Clock.hxx
+7
-0
No files found.
src/Main.cxx
View file @
529b4bd1
...
...
@@ -554,7 +554,6 @@ int mpd_main(int argc, char *argv[])
archive_plugin_deinit_all
();
#endif
config_global_finish
();
stats_global_finish
();
io_thread_deinit
();
SignalHandlersFinish
();
delete
instance
;
...
...
src/Stats.cxx
View file @
529b4bd1
...
...
@@ -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
));
...
...
src/Stats.hxx
View file @
529b4bd1
...
...
@@ -24,8 +24,6 @@ class Client;
void
stats_global_init
(
void
);
void
stats_global_finish
(
void
);
void
stats_update
(
void
);
void
...
...
src/system/Clock.cxx
View file @
529b4bd1
...
...
@@ -31,6 +31,28 @@
#endif
unsigned
MonotonicClockS
(
void
)
{
#ifdef WIN32
return
GetTickCount
()
/
1000
;
#elif defined(__APPLE__)
/* OS X does not define CLOCK_MONOTONIC */
static
mach_timebase_info_data_t
base
;
if
(
base
.
denom
==
0
)
(
void
)
mach_timebase_info
(
&
base
);
return
(
unsigned
)((
mach_absolute_time
()
*
base
.
numer
/
1000
)
/
(
1000000
*
base
.
denom
));
#elif defined(CLOCK_MONOTONIC)
struct
timespec
ts
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
return
ts
.
tv_sec
;
#else
/* we have no monotonic clock, fall back to time() */
return
time
(
nullptr
);
#endif
}
unsigned
MonotonicClockMS
(
void
)
{
#ifdef WIN32
...
...
src/system/Clock.hxx
View file @
529b4bd1
...
...
@@ -25,6 +25,13 @@
#include <stdint.h>
/**
* Returns the value of a monotonic clock in seconds.
*/
gcc_pure
unsigned
MonotonicClockS
();
/**
* Returns the value of a monotonic clock in milliseconds.
*/
gcc_pure
...
...
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