Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
cd3e853f
Commit
cd3e853f
authored
Apr 30, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
d1146ff6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
clock-res/src/clockres.c
clock-res/src/clockres.c
+18
-19
No files found.
clock-res/src/clockres.c
View file @
cd3e853f
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include "tracer.h"
#include "tracer.h"
#define CLOCK_ID CLOCK_MONOTONIC
#define CLOCK_ID CLOCK_MONOTONIC
#define NSEC_PER_SEC INT64_C(1000000000)
#define NSEC_PER_SEC
U
INT64_C(1000000000)
typedef
struct
thread_stat
{
typedef
struct
thread_stat
{
int
nb_cycles
;
int
nb_cycles
;
...
@@ -60,32 +60,32 @@ static void *timerthread(void *p) {
...
@@ -60,32 +60,32 @@ static void *timerthread(void *p) {
stat
->
max_res
=
0
;
stat
->
max_res
=
0
;
stat
->
min_res
=
UINT64_MAX
;
stat
->
min_res
=
UINT64_MAX
;
if
(
param
->
enable_tracing
)
if
(
param
->
enable_tracing
)
tracing
(
1
);
tracing
(
1
);
for
(
stat
->
nb_cycles
=
0
;;
stat
->
nb_cycles
++
)
{
for
(
stat
->
nb_cycles
=
0
;;
stat
->
nb_cycles
++
)
{
if
(
param
->
max_cycles
&&
(
stat
->
nb_cycles
>=
param
->
max_cycles
))
break
;
if
(
param
->
max_cycles
&&
(
stat
->
nb_cycles
>=
param
->
max_cycles
))
break
;
if
(
param
->
enable_tracing
)
if
(
param
->
enable_tracing
)
tracemark
(
"Time measure start
\n
"
);
tracemark
(
"Time measure start
\n
"
);
clock_gettime
(
CLOCK_ID
,
&
previous
);
clock_gettime
(
CLOCK_ID
,
&
previous
);
clock_gettime
(
CLOCK_ID
,
&
current
);
clock_gettime
(
CLOCK_ID
,
&
current
);
if
(
param
->
enable_tracing
)
if
(
param
->
enable_tracing
)
tracemark
(
"Time measure end"
);
tracemark
(
"Time measure end"
);
diff
=
calcdiff_ns
(
current
,
previous
);
diff
=
calcdiff_ns
(
current
,
previous
);
sprintf
(
time_measured_string
,
"Diff measured: %"
PRIu64
"
\n
"
,
diff
);
sprintf
(
time_measured_string
,
"Diff measured: %"
PRIu64
", Current (%ld, %ld), Previous (%ld, %ld)
\n
"
,
diff
,
current
.
tv_sec
,
current
.
tv_nsec
,
previous
.
tv_sec
,
previous
.
tv_nsec
);
if
(
param
->
enable_tracing
)
tracemark
(
time_measured_string
);
if
(
param
->
enable_tracing
)
tracemark
(
time_measured_string
);
stat
->
max_res
=
max
(
stat
->
max_res
,
diff
);
stat
->
max_res
=
max
(
stat
->
max_res
,
diff
);
stat
->
min_res
=
min
(
stat
->
min_res
,
diff
);
stat
->
min_res
=
min
(
stat
->
min_res
,
diff
);
if
(
param
->
enable_tracing
&&
(
diff
>
param
->
latency_threshold
)
)
{
if
(
param
->
enable_tracing
&&
(
diff
>
param
->
latency_threshold
)
)
{
tracing
(
0
);
tracing
(
0
);
break
;
break
;
}
}
...
@@ -93,9 +93,7 @@ static void *timerthread(void *p) {
...
@@ -93,9 +93,7 @@ static void *timerthread(void *p) {
usleep
(
param
->
interval
);
usleep
(
param
->
interval
);
}
}
if
(
param
->
enable_tracing
)
if
(
param
->
enable_tracing
)
tracing
(
0
);
tracing
(
0
);
return
NULL
;
return
NULL
;
}
}
...
@@ -117,7 +115,7 @@ int main(int argc, char *argv[]) {
...
@@ -117,7 +115,7 @@ int main(int argc, char *argv[]) {
process_options
(
argc
,
argv
,
&
param
,
&
main_param
);
process_options
(
argc
,
argv
,
&
param
,
&
main_param
);
if
(
main_param
.
enable_tracing
)
{
if
(
main_param
.
enable_tracing
)
{
param
.
enable_tracing
=
1
;
param
.
enable_tracing
=
1
;
setup_tracer
();
setup_tracer
();
}
}
...
@@ -136,12 +134,13 @@ int main(int argc, char *argv[]) {
...
@@ -136,12 +134,13 @@ int main(int argc, char *argv[]) {
param
.
stat
.
nb_cycles
);
param
.
stat
.
nb_cycles
);
if
(
param
.
max_cycles
==
param
.
stat
.
nb_cycles
)
break
;
if
(
param
.
max_cycles
==
param
.
stat
.
nb_cycles
)
break
;
if
(
main_param
.
enable_tracing
&&
(
param
.
stat
.
max_res
>=
param
.
latency_threshold
))
break
;
if
(
main_param
.
enable_tracing
&&
(
param
.
stat
.
max_res
>=
param
.
latency_threshold
))
break
;
}
}
// Just in case main exists before the thread
// Just in case main exists before the thread
if
(
main_param
.
enable_tracing
)
if
(
main_param
.
enable_tracing
)
tracing
(
0
);
tracing
(
0
);
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
...
...
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