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
6871d290
Commit
6871d290
authored
11 years ago
by
px4dev
Browse files
Options
Downloads
Patches
Plain Diff
Add a mechanism for cancelling begin/end perf counters.
parent
3c8c596a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/systemlib/perf_counter.c
+34
-7
34 additions, 7 deletions
src/modules/systemlib/perf_counter.c
src/modules/systemlib/perf_counter.h
+13
-1
13 additions, 1 deletion
src/modules/systemlib/perf_counter.h
with
47 additions
and
8 deletions
src/modules/systemlib/perf_counter.c
+
34
−
7
View file @
6871d290
...
...
@@ -201,23 +201,50 @@ perf_end(perf_counter_t handle)
switch
(
handle
->
type
)
{
case
PC_ELAPSED
:
{
struct
perf_ctr_elapsed
*
pce
=
(
struct
perf_ctr_elapsed
*
)
handle
;
hrt_abstime
elapsed
=
hrt_absolute_time
()
-
pce
->
time_start
;
pce
->
event_count
++
;
pce
->
time_total
+=
elapsed
;
if
(
pce
->
time_start
!=
0
)
{
hrt_abstime
elapsed
=
hrt_absolute_time
()
-
pce
->
time_start
;
if
((
pce
->
time_least
>
elapsed
)
||
(
pce
->
time_least
==
0
))
pce
->
time_
least
=
elapsed
;
pce
->
event_count
++
;
pce
->
time_
total
+
=
elapsed
;
if
(
pce
->
time_most
<
elapsed
)
pce
->
time_most
=
elapsed
;
if
((
pce
->
time_least
>
elapsed
)
||
(
pce
->
time_least
==
0
))
pce
->
time_least
=
elapsed
;
if
(
pce
->
time_most
<
elapsed
)
pce
->
time_most
=
elapsed
;
pce
->
time_start
=
0
;
}
}
break
;
default:
break
;
}
}
void
perf_cancel
(
perf_counter_t
handle
)
{
if
(
handle
==
NULL
)
return
;
switch
(
handle
->
type
)
{
case
PC_ELAPSED
:
{
struct
perf_ctr_elapsed
*
pce
=
(
struct
perf_ctr_elapsed
*
)
handle
;
pce
->
time_start
=
0
;
}
break
;
default:
break
;
}
}
void
perf_reset
(
perf_counter_t
handle
)
{
...
...
This diff is collapsed.
Click to expand it.
src/modules/systemlib/perf_counter.h
+
13
−
1
View file @
6871d290
...
...
@@ -92,13 +92,25 @@ __EXPORT extern void perf_begin(perf_counter_t handle);
* End a performance event.
*
* This call applies to counters that operate over ranges of time; PC_ELAPSED etc.
* If a call is made without a corresopnding perf_begin call, or if perf_cancel
* has been called subsequently, no change is made to the counter.
*
* @param handle The handle returned from perf_alloc.
*/
__EXPORT
extern
void
perf_end
(
perf_counter_t
handle
);
/**
* Reset a performance event.
* Cancel a performance event.
*
* This call applies to counters that operate over ranges of time; PC_ELAPSED etc.
* It reverts the effect of a previous perf_begin.
*
* @param handle The handle returned from perf_alloc.
*/
__EXPORT
extern
void
perf_cancel
(
perf_counter_t
handle
);
/**
* Reset a performance counter.
*
* This call resets performance counter to initial state
*
...
...
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