Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
3b898ac3
Commit
3b898ac3
authored
1 year ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
timer.cc: cleanup
parent
a456a9b0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!75
M214003/develop
Pipeline
#38074
passed
1 year ago
Stage: build
Stage: check
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/timer.cc
+15
-28
15 additions, 28 deletions
src/timer.cc
with
15 additions
and
28 deletions
src/timer.cc
+
15
−
28
View file @
3b898ac3
...
...
@@ -5,20 +5,14 @@
*/
#ifdef HAVE_CONFIG_H
#include
"config.h"
#endif
#include
<stdio.h>
#include
<string.h>
#include
<unistd.h>
#include
"cdo_timer.h"
#include
"timer.h"
int
timer_read
,
timer_write
;
FILE
*
rt_unit
=
nullpt
r
;
static
FILE
*
rt_unit
=
stder
r
;
enum
{
...
...
@@ -27,17 +21,17 @@ enum
rt_stat_off
};
/
*
minimal internal time needed to do one measurement
*/
/
/
minimal internal time needed to do one measurement
double
tm_shift
=
0.0
;
static
double
tm_shift
=
0.0
;
/
*
average total overhead for one timer_start & timer_stop pair
*/
/
/
average total overhead for one timer_start & timer_stop pair
double
tm_overhead
=
0.0
;
static
double
tm_overhead
=
0.0
;
#def
in
e
MAX_TIMER 128
/*
max number of timers allowed
*/
constexpr
in
t
MAX_TIMER
=
128
;
//
max number of timers allowed
struct
R
T_TYPE
struct
R
ealTimer
{
int
reserved
=
0
;
int
calls
=
0
;
...
...
@@ -50,9 +44,9 @@ struct RT_TYPE
std
::
string
text
;
};
RT_TYPE
rt
[
MAX_TIMER
];
int
timer_need_init
=
1
;
int
top_timer
=
0
;
static
RealTimer
rt
[
MAX_TIMER
];
static
int
timer_need_init
=
1
;
static
int
top_timer
=
0
;
static
double
get_time_val
(
double
mark0
)
...
...
@@ -62,7 +56,7 @@ get_time_val(double mark0)
return
dt
;
}
int
ntests
=
100
;
/
*
tests need about n microsecs
on pwr4 */
constexpr
int
ntests
=
100
;
/
/ tests need about n microsecs
static
double
m1
(
void
)
...
...
@@ -105,10 +99,7 @@ estimate_overhead(void)
static
void
timer_init
(
void
)
{
rt_unit
=
stderr
;
estimate_overhead
();
timer_need_init
=
0
;
}
...
...
@@ -124,7 +115,7 @@ timer_new(const std::string &text)
fprintf
(
stderr
,
"timer_new: MAX_TIMER too small!
\n
"
);
}
int
it
=
top_timer
;
auto
it
=
top_timer
;
top_timer
++
;
rt
[
it
].
reserved
=
1
;
...
...
@@ -147,10 +138,7 @@ timer_val(int it)
auto
val
=
rt
[
it
].
tot
;
if
(
rt
[
it
].
stat
==
rt_stat_on
)
{
val
+=
get_time_val
(
rt
[
it
].
mark1
);
}
if
(
rt
[
it
].
stat
==
rt_stat_on
)
{
val
+=
get_time_val
(
rt
[
it
].
mark1
);
}
return
val
;
}
...
...
@@ -169,9 +157,8 @@ timer_report(void)
for
(
int
it
=
0
;
it
<
top_timer
;
it
++
)
{
double
total
=
timer_val
(
it
);
double
avg
=
rt
[
it
].
tot
;
auto
total
=
timer_val
(
it
);
auto
avg
=
rt
[
it
].
tot
;
if
(
rt
[
it
].
calls
>
0
)
avg
/=
rt
[
it
].
calls
;
if
(
rt
[
it
].
stat
!=
rt_stat_undef
)
...
...
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