Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
677bfddc
Commit
677bfddc
authored
10 years ago
by
Lorenz Meier
Browse files
Options
Downloads
Patches
Plain Diff
uORB: More timing tests.
parent
3355d77e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/uORB/uORB.cpp
+50
-4
50 additions, 4 deletions
src/modules/uORB/uORB.cpp
with
50 additions
and
4 deletions
src/modules/uORB/uORB.cpp
+
50
−
4
View file @
677bfddc
...
...
@@ -684,6 +684,8 @@ namespace
ORBDevMaster
*
g_dev
;
bool
pubsubtest_passed
=
false
;
bool
pubsubtest_print
=
false
;
int
pubsubtest_res
=
OK
;
struct
orb_test
{
int
val
;
...
...
@@ -736,7 +738,9 @@ int pubsublatency_main(void)
struct
orb_test
t
;
const
unsigned
maxruns
=
10
;
const
unsigned
maxruns
=
1000
;
unsigned
*
timings
=
new
unsigned
[
maxruns
];
for
(
unsigned
i
=
0
;
i
<
maxruns
;
i
++
)
{
/* wait for up to 500ms for data */
...
...
@@ -750,17 +754,34 @@ int pubsublatency_main(void)
hrt_abstime
elt
=
hrt_elapsed_time
(
&
t
.
time
);
latency_integral
+=
elt
;
timings
[
i
]
=
elt
;
}
orb_unsubscribe
(
test_multi_sub
);
if
(
pubsubtest_print
)
{
for
(
unsigned
i
=
0
;
i
<
maxruns
;
i
++
)
{
printf
(
"%u
\n
"
,
timings
[
i
]);
}
}
delete
[]
timings
;
warnx
(
"mean: %8.4f"
,
static_cast
<
double
>
(
latency_integral
/
maxruns
));
pubsubtest_passed
=
true
;
return
OK
;
if
(
static_cast
<
float
>
(
latency_integral
/
maxruns
)
>
30.0
f
)
{
pubsubtest_res
=
ERROR
;
}
else
{
pubsubtest_res
=
OK
;
}
return
pubsubtest_res
;
}
int
latency_test
(
bool
print
);
int
test
()
{
...
...
@@ -874,6 +895,25 @@ test()
if
(
prio
!=
ORB_PRIO_MIN
)
return
test_fail
(
"prio: %d"
,
prio
);
if
(
OK
!=
latency_test
(
false
))
return
test_fail
(
"latency test failed"
);
return
test_note
(
"PASS"
);
}
int
latency_test
(
bool
print
)
{
struct
orb_test
t
;
t
.
val
=
308
;
t
.
time
=
hrt_absolute_time
();
int
pfd0
=
orb_advertise
(
ORB_ID
(
orb_multitest
),
&
t
);
pubsubtest_print
=
print
;
pubsubtest_passed
=
false
;
/* test pub / sub latency */
int
pubsub_task
=
task_spawn_cmd
(
"uorb_latency"
,
...
...
@@ -885,7 +925,7 @@ test()
/* give the test task some data */
while
(
!
pubsubtest_passed
)
{
t
.
val
=
30
3
;
t
.
val
=
30
8
;
t
.
time
=
hrt_absolute_time
();
if
(
OK
!=
orb_publish
(
ORB_ID
(
orb_multitest
),
pfd0
,
&
t
))
return
test_fail
(
"mult. pub0 timing fail"
);
...
...
@@ -898,7 +938,7 @@ test()
return
test_fail
(
"failed launching task"
);
}
return
test_note
(
"PASS"
)
;
return
pubsubtest_res
;
}
int
...
...
@@ -955,6 +995,12 @@ uorb_main(int argc, char *argv[])
if
(
!
strcmp
(
argv
[
1
],
"test"
))
return
test
();
/*
* Test the latency.
*/
if
(
!
strcmp
(
argv
[
1
],
"latency_test"
))
return
latency_test
(
true
);
/*
* Print driver information.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment