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
02829888
Commit
02829888
authored
Apr 30, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Making tracing optional
parent
a7d3c837
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
clock-res/src/clockres.c
clock-res/src/clockres.c
+21
-6
No files found.
clock-res/src/clockres.c
View file @
02829888
...
@@ -24,6 +24,7 @@ typedef struct thread_stat {
...
@@ -24,6 +24,7 @@ typedef struct thread_stat {
typedef
struct
thread_param
{
typedef
struct
thread_param
{
int
priority
;
int
priority
;
int
max_cycles
;
int
max_cycles
;
int
enable_tracing
;
uint64_t
interval
;
uint64_t
interval
;
uint64_t
latency_threshold
;
uint64_t
latency_threshold
;
thread_stat_t
stat
;
thread_stat_t
stat
;
...
@@ -31,6 +32,7 @@ typedef struct thread_param {
...
@@ -31,6 +32,7 @@ typedef struct thread_param {
typedef
struct
main_param
{
typedef
struct
main_param
{
int
refresh_rate
;
int
refresh_rate
;
int
enable_tracing
;
}
main_param_t
;
}
main_param_t
;
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
...
@@ -60,17 +62,21 @@ static void *timerthread(void *p) {
...
@@ -60,17 +62,21 @@ static void *timerthread(void *p) {
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
;
tracing
(
1
);
if
(
param
->
enable_tracing
)
tracing
(
1
);
clock_gettime
(
CLOCK_ID
,
&
previous
);
clock_gettime
(
CLOCK_ID
,
&
previous
);
clock_gettime
(
CLOCK_ID
,
&
current
);
clock_gettime
(
CLOCK_ID
,
&
current
);
tracing
(
0
);
if
(
param
->
enable_tracing
)
tracing
(
0
);
diff
=
calcdiff_ns
(
current
,
previous
);
diff
=
calcdiff_ns
(
current
,
previous
);
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
(
diff
>
param
->
latency_threshold
)
break
;
if
(
param
->
enable_tracing
&&
(
diff
>
param
->
latency_threshold
)
)
break
;
usleep
(
param
->
interval
);
usleep
(
param
->
interval
);
}
}
...
@@ -89,10 +95,16 @@ int main(int argc, char *argv[]) {
...
@@ -89,10 +95,16 @@ int main(int argc, char *argv[]) {
param
.
interval
=
1000
;
param
.
interval
=
1000
;
param
.
max_cycles
=
100000
;
param
.
max_cycles
=
100000
;
param
.
priority
=
99
;
param
.
priority
=
99
;
param
.
enable_tracing
=
0
;
main_param
.
enable_tracing
=
0
;
main_param
.
refresh_rate
=
10000
;
main_param
.
refresh_rate
=
10000
;
process_options
(
argc
,
argv
,
&
param
,
&
main_param
);
process_options
(
argc
,
argv
,
&
param
,
&
main_param
);
setup_tracer
();
if
(
main_param
.
enable_tracing
)
{
param
.
enable_tracing
=
1
;
setup_tracer
();
}
usleep
(
10000
);
usleep
(
10000
);
...
@@ -108,7 +120,7 @@ int main(int argc, char *argv[]) {
...
@@ -108,7 +120,7 @@ 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
(
param
.
stat
.
max_res
>=
param
.
latency_threshold
)
break
;
if
(
main_param
.
enable_tracing
&&
(
param
.
stat
.
max_res
>=
param
.
latency_threshold
)
)
break
;
}
}
tracing
(
0
);
tracing
(
0
);
...
@@ -119,7 +131,7 @@ int main(int argc, char *argv[]) {
...
@@ -119,7 +131,7 @@ int main(int argc, char *argv[]) {
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
main_param_t
*
main_param
)
{
main_param_t
*
main_param
)
{
for
(;;)
{
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"l:p:i:r:b:"
);
int
c
=
getopt
(
argc
,
argv
,
"l:p:i:r:b:
f:
"
);
if
(
c
==
-
1
)
break
;
if
(
c
==
-
1
)
break
;
...
@@ -139,6 +151,9 @@ static void process_options(int argc, char *argv[], thread_param_t *param,
...
@@ -139,6 +151,9 @@ static void process_options(int argc, char *argv[], thread_param_t *param,
case
'r'
:
case
'r'
:
main_param
->
refresh_rate
=
atoi
(
optarg
);
main_param
->
refresh_rate
=
atoi
(
optarg
);
break
;
break
;
case
'f'
:
main_param
->
enable_tracing
=
1
;
break
;
default:
default:
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
break
;
break
;
...
...
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