Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ag-ohlberger
dune-community
dune-xt
Commits
fcc5f2e6
Commit
fcc5f2e6
authored
14 years ago
by
René Fritze
Browse files
Options
Downloads
Patches
Plain Diff
loop timer changes
parent
f886cfe6
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
stuff/profiler.hh
+47
-6
47 additions, 6 deletions
stuff/profiler.hh
with
47 additions
and
6 deletions
stuff/profiler.hh
+
47
−
6
View file @
fcc5f2e6
...
@@ -344,24 +344,63 @@ Profiler& profiler()
...
@@ -344,24 +344,63 @@ Profiler& profiler()
}
}
namespace
Stuff
{
namespace
Stuff
{
struct
IdentityWeights
{
double
apply
(
const
double
to_weigh
,
const
int
/*current*/
,
const
int
/*max*/
)
{
return
to_weigh
;
}
};
struct
LinearWeights
{
double
apply
(
const
double
to_weigh
,
const
int
current
,
const
int
max
)
{
return
to_weigh
/
(
current
/
double
(
max
));
}
};
struct
QuadraticWeights
{
double
apply
(
const
double
to_weigh
,
const
int
current
,
const
int
max
)
{
return
to_weigh
/
std
::
pow
(
current
/
double
(
max
),
2.0
);
}
};
struct
ProgressiveWeights
{
const
int
prog_
;
ProgressiveWeights
(
const
int
prog
)
:
prog_
(
prog
)
{
}
double
apply
(
const
double
to_weigh
,
const
int
/*current*/
,
const
int
/*max*/
)
{
return
to_weigh
*
prog_
;
}
};
//! helper class to estimate time needed to complete a loop with given counter
//! helper class to estimate time needed to complete a loop with given counter
template
<
class
CounterType
,
class
OutputStreamType
>
template
<
class
CounterType
,
class
OutputStreamType
,
class
WeightType
=
IdentityWeights
>
class
LoopTimer
class
LoopTimer
{
{
typedef
LoopTimer
<
CounterType
,
OutputStreamType
>
ThisType
;
typedef
LoopTimer
<
CounterType
,
OutputStreamType
,
WeightType
>
ThisType
;
CounterType
&
counter_
;
CounterType
&
counter_
;
const
int
iteration_count_
;
const
int
iteration_count_
;
int
iteration_
;
int
iteration_
;
OutputStreamType
&
output_stream_
;
OutputStreamType
&
output_stream_
;
WeightType
weight_
;
MovingAverage
avg_time_per_iteration_
;
MovingAverage
avg_time_per_iteration_
;
Dune
::
ExecutionTimer
step_timer_
;
Dune
::
ExecutionTimer
step_timer_
;
public:
public:
LoopTimer
(
CounterType
&
counter
,
const
int
iteration_count
,
OutputStreamType
&
output_stream
=
std
::
cout
)
LoopTimer
(
CounterType
&
counter
,
const
int
iteration_count
,
OutputStreamType
&
output_stream
=
std
::
cout
,
WeightType
weight
=
WeightType
())
:
counter_
(
counter
)
:
counter_
(
counter
)
,
iteration_count_
(
iteration_count
)
,
iteration_count_
(
iteration_count
)
,
iteration_
(
0
)
,
iteration_
(
0
)
,
output_stream_
(
output_stream
)
,
output_stream_
(
output_stream
)
,
weight_
(
weight
)
{
{
step_timer_
.
start
();
step_timer_
.
start
();
}
}
...
@@ -370,12 +409,14 @@ public:
...
@@ -370,12 +409,14 @@ public:
{
{
++
iteration_
;
++
iteration_
;
step_timer_
.
end
();
step_timer_
.
end
();
avg_time_per_iteration_
+=
std
::
abs
(
step_timer_
.
read
());
avg_time_per_iteration_
+=
weight_
.
apply
(
std
::
abs
(
step_timer_
.
read
())
,
iteration_
,
iteration_count_
)
;
long
remaining_steps
=
iteration_count_
-
iteration_
;
long
remaining_steps
=
iteration_count_
-
iteration_
;
double
remaining_seconds
=
remaining_steps
*
double
(
avg_time_per_iteration_
);
double
remaining_seconds
=
remaining_steps
*
double
(
avg_time_per_iteration_
);
boost
::
posix_time
::
time_duration
diff
(
0
,
0
,
remaining_seconds
,
0
);
boost
::
posix_time
::
time_duration
diff
(
0
,
0
,
remaining_seconds
,
0
);
output_stream_
<<
boost
::
format
(
"
\n
---
\n
Total Time remaining: %s (%f %%)
\n
---
\n
"
)
boost
::
posix_time
::
ptime
target
=
boost
::
posix_time
::
second_clock
::
local_time
();
%
boost
::
posix_time
::
to_simple_string
(
diff
)
target
+=
diff
;
output_stream_
<<
boost
::
format
(
"
\n
---
\n
Total Time remaining: %s -- %s (%f %%)
\n
---
\n
"
)
%
boost
::
posix_time
::
to_simple_string
(
diff
)
%
boost
::
posix_time
::
to_simple_string
(
target
)
%
(
100
*
(
remaining_steps
/
double
(
iteration_count_
)))
%
(
100
*
(
remaining_steps
/
double
(
iteration_count_
)))
<<
std
::
endl
;
<<
std
::
endl
;
step_timer_
.
start
();
step_timer_
.
start
();
...
...
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