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
633b894b
Commit
633b894b
authored
14 years ago
by
René Fritze
Browse files
Options
Downloads
Patches
Plain Diff
new loop timer
parent
a9889b7c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stuff/profiler.hh
+47
-0
47 additions, 0 deletions
stuff/profiler.hh
with
47 additions
and
0 deletions
stuff/profiler.hh
+
47
−
0
View file @
633b894b
...
@@ -3,13 +3,17 @@
...
@@ -3,13 +3,17 @@
#include
<dune/common/exceptions.hh>
#include
<dune/common/exceptions.hh>
#include
<dune/fem/misc/femtimer.hh>
#include
<string>
#include
<string>
#include
<iostream>
#include
<iostream>
#include
<map>
#include
<map>
#include
<vector>
#include
<vector>
#include
<ctime>
#include
<ctime>
#include
<boost/foreach.hpp>
#include
<boost/foreach.hpp>
#include
<boost/format.hpp>
#include
<boost/format.hpp>
#include
<boost/date_time/posix_time/posix_time.hpp>
#include
"misc.hh"
#include
"misc.hh"
#include
"debug.hh"
#include
"debug.hh"
...
@@ -339,4 +343,47 @@ Profiler& profiler()
...
@@ -339,4 +343,47 @@ Profiler& profiler()
return
Profiler
::
instance
();
return
Profiler
::
instance
();
}
}
namespace
Stuff
{
//! helper class to estimate time needed to complete a loop with given counter
template
<
class
CounterType
,
class
OutputStreamType
>
class
LoopTimer
{
typedef
LoopTimer
<
CounterType
,
OutputStreamType
>
ThisType
;
CounterType
&
counter_
;
const
int
iteration_count_
;
int
iteration_
;
OutputStreamType
&
output_stream_
;
MovingAverage
avg_time_per_iteration_
;
Dune
::
ExecutionTimer
step_timer_
;
public:
LoopTimer
(
CounterType
&
counter
,
const
int
iteration_count
,
OutputStreamType
&
output_stream
=
std
::
cout
)
:
counter_
(
counter
)
,
iteration_count_
(
iteration_count
)
,
iteration_
(
0
)
,
output_stream_
(
output_stream
)
{
step_timer_
.
start
();
}
ThisType
&
operator
++
()
{
++
iteration_
;
step_timer_
.
end
();
avg_time_per_iteration_
+=
std
::
abs
(
step_timer_
.
read
());
long
remaining_steps
=
iteration_count_
-
iteration_
;
double
remaining_seconds
=
remaining_steps
*
double
(
avg_time_per_iteration_
);
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
::
to_simple_string
(
diff
)
%
(
100
*
(
remaining_steps
/
double
(
iteration_count_
)))
<<
std
::
endl
;
step_timer_
.
start
();
++
counter_
;
return
*
this
;
}
};
}
// namespace Stuff
#endif // DUNE_STUFF_PROFILER_HH_INCLUDED
#endif // DUNE_STUFF_PROFILER_HH_INCLUDED
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