Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
7606f50a
Commit
7606f50a
authored
Nov 10, 2015
by
Hugo Beauzée-Luyssen
Browse files
SqliteTools: Log request durations
parent
2bd1418d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/database/SqliteTools.h
View file @
7606f50a
...
...
@@ -24,6 +24,7 @@
#define SQLITETOOLS_H
#include
<cassert>
#include
<chrono>
#include
<cstring>
#include
<memory>
#include
<sqlite3.h>
...
...
@@ -312,6 +313,7 @@ class Tools
static
std
::
vector
<
std
::
shared_ptr
<
INTF
>
>
fetchAll
(
DBConnection
dbConnection
,
const
std
::
string
&
req
,
Args
&&
...
args
)
{
auto
ctx
=
dbConnection
->
acquireContext
();
auto
chrono
=
std
::
chrono
::
steady_clock
::
now
();
std
::
vector
<
std
::
shared_ptr
<
INTF
>>
results
;
auto
stmt
=
Statement
(
dbConnection
,
req
);
...
...
@@ -322,6 +324,9 @@ class Tools
auto
row
=
IMPL
::
load
(
dbConnection
,
sqliteRow
);
results
.
push_back
(
row
);
}
auto
duration
=
std
::
chrono
::
steady_clock
::
now
()
-
chrono
;
LOG_DEBUG
(
"Executed "
,
req
,
" in "
,
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
duration
).
count
(),
"µs"
);
return
results
;
}
...
...
@@ -329,13 +334,18 @@ class Tools
static
std
::
shared_ptr
<
T
>
fetchOne
(
DBConnection
dbConnection
,
const
std
::
string
&
req
,
Args
&&
...
args
)
{
auto
ctx
=
dbConnection
->
acquireContext
();
auto
chrono
=
std
::
chrono
::
steady_clock
::
now
();
auto
stmt
=
Statement
(
dbConnection
,
req
);
stmt
.
execute
(
std
::
forward
<
Args
>
(
args
)...
);
auto
row
=
stmt
.
row
();
if
(
row
==
nullptr
)
return
nullptr
;
return
T
::
load
(
dbConnection
,
row
);
auto
res
=
T
::
load
(
dbConnection
,
row
);
auto
duration
=
std
::
chrono
::
steady_clock
::
now
()
-
chrono
;
LOG_DEBUG
(
"Executed "
,
req
,
" in "
,
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
duration
).
count
(),
"µs"
);
return
res
;
}
template
<
typename
...
Args
>
...
...
@@ -378,10 +388,14 @@ class Tools
template
<
typename
...
Args
>
static
bool
executeRequestLocked
(
DBConnection
dbConnection
,
const
std
::
string
&
req
,
Args
&&
...
args
)
{
auto
chrono
=
std
::
chrono
::
steady_clock
::
now
();
auto
stmt
=
Statement
(
dbConnection
,
req
);
stmt
.
execute
(
std
::
forward
<
Args
>
(
args
)...
);
while
(
stmt
.
row
()
!=
nullptr
)
;
auto
duration
=
std
::
chrono
::
steady_clock
::
now
()
-
chrono
;
LOG_DEBUG
(
"Executed "
,
req
,
" in "
,
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
duration
).
count
(),
"µs"
);
return
true
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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