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
7df8e1ea
Commit
7df8e1ea
authored
Aug 29, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/Count: use std::chrono::duration for the total time
Use milliseconds precision to reduce rounding errors.
parent
31589551
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
Count.cxx
src/db/Count.cxx
+9
-6
No files found.
src/db/Count.cxx
View file @
7df8e1ea
...
...
@@ -30,10 +30,10 @@
struct
SearchStats
{
unsigned
n_songs
;
unsigned
long
total_time_s
;
std
::
chrono
::
duration
<
std
::
uint64_t
,
SongTime
::
period
>
total_duration
;
constexpr
SearchStats
()
:
n_songs
(
0
),
total_
time_s
(
0
)
{}
:
n_songs
(
0
),
total_
duration
(
0
)
{}
};
class
TagCountMap
:
public
std
::
map
<
std
::
string
,
SearchStats
>
{
...
...
@@ -42,10 +42,13 @@ class TagCountMap : public std::map<std::string, SearchStats> {
static
void
PrintSearchStats
(
Client
&
client
,
const
SearchStats
&
stats
)
{
unsigned
total_duration_s
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
stats
.
total_duration
).
count
();
client_printf
(
client
,
"songs: %u
\n
"
"playtime: %
l
u
\n
"
,
stats
.
n_songs
,
stats
.
total_time
_s
);
"playtime: %u
\n
"
,
stats
.
n_songs
,
total_duration
_s
);
}
static
void
...
...
@@ -67,7 +70,7 @@ stats_visitor_song(SearchStats &stats, const LightSong &song)
const
auto
duration
=
song
.
GetDuration
();
if
(
!
duration
.
IsNegative
())
stats
.
total_
time_s
+=
duration
.
ToS
()
;
stats
.
total_
duration
+=
duration
;
return
true
;
}
...
...
@@ -83,7 +86,7 @@ CollectGroupCounts(TagCountMap &map, TagType group, const Tag &tag)
SearchStats
&
s
=
r
.
first
->
second
;
++
s
.
n_songs
;
if
(
!
tag
.
duration
.
IsNegative
())
s
.
total_
time_s
+=
tag
.
duration
.
ToS
()
;
s
.
total_
duration
+=
tag
.
duration
;
found
=
true
;
}
...
...
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