Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DIO 5ch TTL a
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DIO 5ch TTL a
Commits
d83d33ac
Commit
d83d33ac
authored
Oct 21, 2020
by
Miguel Jimenez Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
irq-demo: Implement new metrics for stats-engine (max and min)
parent
f4e96462
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
2 deletions
+48
-2
stats-engine-private.h
sw/irq-demo/dep/stats-engine-private.h
+6
-0
stats-engine.c
sw/irq-demo/dep/stats-engine.c
+42
-2
No files found.
sw/irq-demo/dep/stats-engine-private.h
View file @
d83d33ac
...
...
@@ -22,6 +22,8 @@
struct
ts_stats
{
double
mean
;
double
std
;
double
min
;
double
max
;
unsigned
int
ts_per_second
;
unsigned
int
ts_total
;
};
...
...
@@ -56,6 +58,10 @@ static void LOG(stats_engine engine, const char *fmt, ...);
static
int
timespec_subtract
(
struct
timespec
*
result
,
struct
timespec
*
x
,
struct
timespec
*
y
);
static
double
compute_min
(
const
double
*
values
,
const
unsigned
int
n_values
);
static
double
compute_max
(
const
double
*
values
,
const
unsigned
int
n_values
);
static
double
compute_mean
(
const
double
*
values
,
const
unsigned
int
n_values
);
static
double
compute_stdev
(
const
double
*
values
,
...
...
sw/irq-demo/dep/stats-engine.c
View file @
d83d33ac
...
...
@@ -92,6 +92,8 @@ int run_stats_engine(stats_engine engine, int verbose)
neg
=
timespec_subtract
(
&
ts
,
&
engine
->
sys_ts
[
engine
->
current_ts
],
&
(
engine
->
usr_ts
[
engine
->
current_ts
].
t
));
engine
->
diff_ts
[
engine
->
current_ts
]
=
((
neg
)
?
-
1
.
0
:
1
.
0
)
*
(
ts
.
tv_sec
+
((
double
)
ts
.
tv_nsec
/
NS_IN_A_SEC
));
engine
->
stats
.
min
=
compute_min
(
engine
->
diff_ts
,
engine
->
n_ts
);
engine
->
stats
.
max
=
compute_max
(
engine
->
diff_ts
,
engine
->
n_ts
);
engine
->
stats
.
mean
=
compute_mean
(
engine
->
diff_ts
,
engine
->
n_ts
);
engine
->
stats
.
std
=
compute_stdev
(
engine
->
diff_ts
,
engine
->
n_ts
,
engine
->
stats
.
mean
);
count_ts
=
compute_ts_per_second
(
engine
->
usr_ts
[
engine
->
current_ts
].
t
.
tv_sec
,
...
...
@@ -157,9 +159,11 @@ static void log_stats_engine(stats_engine engine, int verbose)
}
LOG
(
engine
,
"
\n
Metrics => Total timestamps: %d, Timestamps per second: %d
\n
"
"max: %f %s, min %f %s
\n
"
"mean: %f %s, stdev: %f %s"
,
engine
->
stats
.
ts_total
,
engine
->
stats
.
ts_per_second
,
engine
->
stats
.
mean
,
METRICS_UNIT
,
engine
->
stats
.
std
,
METRICS_UNIT
);
engine
->
stats
.
ts_total
,
engine
->
stats
.
ts_per_second
,
engine
->
stats
.
max
,
METRICS_UNIT
,
engine
->
stats
.
min
,
METRICS_UNIT
,
engine
->
stats
.
mean
,
METRICS_UNIT
,
engine
->
stats
.
std
,
METRICS_UNIT
);
LOG
(
engine
,
"
\n
============================================================
\n
"
);
log_clear
(
engine
);
}
...
...
@@ -242,6 +246,42 @@ static int timespec_subtract(struct timespec *result,
return
(
result
->
tv_sec
<
0
)
||
(
result
->
tv_nsec
<
0
);
}
static
double
compute_min
(
const
double
*
values
,
const
unsigned
int
n_values
)
{
double
min
=
0
.
0
;
if
(
n_values
==
0
)
return
min
;
min
=
values
[
0
];
for
(
int
i
=
1
;
i
<
n_values
;
i
++
)
{
if
(
values
[
i
]
<
min
)
min
=
values
[
i
];
}
return
min
;
}
static
double
compute_max
(
const
double
*
values
,
const
unsigned
int
n_values
)
{
double
max
=
0
.
0
;
if
(
n_values
==
0
)
return
max
;
max
=
values
[
0
];
for
(
int
i
=
1
;
i
<
n_values
;
i
++
)
{
if
(
values
[
i
]
>
max
)
max
=
values
[
i
];
}
return
max
;
}
static
double
compute_mean
(
const
double
*
values
,
const
unsigned
int
n_values
)
{
...
...
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