Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
28
Issues
28
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
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
Software for White Rabbit PTP Core
Commits
64dd3140
Commit
64dd3140
authored
Feb 15, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc_main and cmd_ps: profile time and report it
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
9983a058
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
13 deletions
+46
-13
wrc-task.h
include/wrc-task.h
+3
-1
cmd_ps.c
shell/cmd_ps.c
+8
-7
wrc_main.c
wrc_main.c
+35
-5
No files found.
include/wrc-task.h
View file @
64dd3140
...
...
@@ -18,7 +18,9 @@ struct wrc_task {
void
(
*
init
)(
void
);
int
(
*
job
)(
void
);
/* And we keep statistics about cpu usage */
unsigned
long
nrun
;
unsigned
long
nrun
;
unsigned
long
seconds
;
unsigned
long
nanos
;
};
...
...
shell/cmd_ps.c
View file @
64dd3140
...
...
@@ -15,20 +15,21 @@ extern int wrc_n_tasks;
static
int
cmd_ps
(
const
char
*
args
[])
{
int
i
,
ena
;
int
i
;
struct
wrc_task
*
t
;
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"reset"
))
{
for
(
i
=
0
;
i
<
wrc_n_tasks
;
i
++
)
{
wrc_tasks
[
i
].
nrun
=
0
;
t
=
wrc_tasks
+
i
;
t
->
nrun
=
t
->
seconds
=
t
->
nanos
=
0
;
}
return
0
;
}
pp_printf
(
"
iterations ena
name
\n
"
);
pp_printf
(
"
iterations seconds.micros
name
\n
"
);
for
(
i
=
0
;
i
<
wrc_n_tasks
;
i
++
)
{
ena
=
1
;
if
(
wrc_tasks
[
i
].
enable
)
ena
=
(
*
wrc_tasks
[
i
].
enable
!=
0
);
pp_printf
(
" %8i %i %s
\n
"
,
wrc_tasks
[
i
].
nrun
,
ena
,
wrc_tasks
[
i
].
name
);
t
=
wrc_tasks
+
i
;
pp_printf
(
" %9li %9li.%06li %s
\n
"
,
t
->
nrun
,
t
->
seconds
,
t
->
nanos
/
1000
,
t
->
name
);
}
return
0
;
}
...
...
wrc_main.c
View file @
64dd3140
...
...
@@ -44,6 +44,8 @@ int32_t sfp_deltaTx = 0;
int32_t
sfp_deltaRx
=
0
;
uint32_t
cal_phase_transition
=
2389
;
static
uint32_t
prev_nanos_for_profile
;
static
void
wrc_initialize
(
void
)
{
uint8_t
mac_addr
[
6
];
...
...
@@ -97,6 +99,7 @@ static void wrc_initialize(void)
wrc_ptp_set_mode
(
WRC_MODE_SLAVE
);
wrc_ptp_start
();
shw_pps_gen_get_time
(
NULL
,
&
prev_nanos_for_profile
);
}
int
link_status
;
...
...
@@ -224,13 +227,40 @@ struct wrc_task wrc_tasks[] = {
int
wrc_n_tasks
=
ARRAY_SIZE
(
wrc_tasks
);
/* Account the time to either this task or task 0 */
static
void
account_task
(
struct
wrc_task
*
t
,
int
done_sth
)
{
uint32_t
nanos
;
signed
int
delta
;
if
(
!
done_sth
)
t
=
wrc_tasks
;
shw_pps_gen_get_time
(
NULL
,
&
nanos
);
delta
=
nanos
-
prev_nanos_for_profile
;
if
(
delta
<
0
)
delta
+=
1000
*
1000
*
1000
;
t
->
nanos
+=
delta
;
if
(
t
->
nanos
>
1000
*
1000
*
1000
)
{
t
->
nanos
-=
1000
*
1000
*
1000
;
t
->
seconds
++
;
}
prev_nanos_for_profile
=
nanos
;
}
/* Run a task with profiling */
static
void
wrc_run_task
(
struct
wrc_task
*
t
)
{
if
(
t
->
enable
&&
!*
t
->
enable
)
return
;
if
(
t
->
job
)
t
->
nrun
+=
t
->
job
();
else
t
->
nrun
++
;
int
done_sth
=
0
;
if
(
!
t
->
job
)
/* idle task, just count iterations */
t
->
nrun
++
;
else
if
(
!
t
->
enable
||
*
t
->
enable
)
{
/* either enabled or without a check variable */
done_sth
=
t
->
job
();
t
->
nrun
+=
done_sth
;
}
account_task
(
t
,
done_sth
);
}
int
main
(
void
)
...
...
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