Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Plumed AlphaFold
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Martin Kurečka
Plumed AlphaFold
Commits
0a2f726c
There was an error fetching the commit references. Please try again later.
Commit
0a2f726c
authored
5 years ago
by
Giovanni Bussi
Browse files
Options
Downloads
Patches
Plain Diff
Fix Stopwatch to avoid unique global symbols
See #549
parent
521e06b7
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
src/tools/Stopwatch.h
+13
-11
13 additions, 11 deletions
src/tools/Stopwatch.h
with
13 additions
and
11 deletions
src/tools/Stopwatch.h
+
13
−
11
View file @
0a2f726c
...
@@ -165,13 +165,15 @@ This will make sure timers are written also in case of a premature end.
...
@@ -165,13 +165,15 @@ This will make sure timers are written also in case of a premature end.
class
Log
;
class
Log
;
/// Return an empty string.
/// Inline static so that it can store a static variable (for quicker access)
/// without adding a unique global symbol to a library including this header file.
inline
static
const
std
::
string
&
StopwatchEmptyString
()
noexcept
{
const
static
std
::
string
s
;
return
s
;
}
class
Stopwatch
{
class
Stopwatch
{
/// Simple function returning an empty string.
/// Used to simplify Stopwatch interface.
static
const
std
::
string
&
emptyString
()
{
static
std
::
string
s
;
return
s
;
}
public:
public:
/// Forward declaration
/// Forward declaration
...
@@ -263,23 +265,23 @@ public:
...
@@ -263,23 +265,23 @@ public:
// Destructor.
// Destructor.
~
Stopwatch
();
~
Stopwatch
();
/// Start timer named "name"
/// Start timer named "name"
Stopwatch
&
start
(
const
std
::
string
&
name
=
e
mptyString
());
Stopwatch
&
start
(
const
std
::
string
&
name
=
StopwatchE
mptyString
());
/// Stop timer named "name"
/// Stop timer named "name"
Stopwatch
&
stop
(
const
std
::
string
&
name
=
e
mptyString
());
Stopwatch
&
stop
(
const
std
::
string
&
name
=
StopwatchE
mptyString
());
/// Pause timer named "name"
/// Pause timer named "name"
Stopwatch
&
pause
(
const
std
::
string
&
name
=
e
mptyString
());
Stopwatch
&
pause
(
const
std
::
string
&
name
=
StopwatchE
mptyString
());
/// Dump all timers on an ostream
/// Dump all timers on an ostream
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
Stopwatch
&
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
Stopwatch
&
);
/// Start with exception safety, then stop.
/// Start with exception safety, then stop.
/// Starts the Stopwatch and returns an object that, when goes out of scope,
/// Starts the Stopwatch and returns an object that, when goes out of scope,
/// stops the watch. This allows Stopwatch to be started and stopped in
/// stops the watch. This allows Stopwatch to be started and stopped in
/// an exception safe manner.
/// an exception safe manner.
Handler
startStop
(
const
std
::
string
&
name
=
e
mptyString
());
Handler
startStop
(
const
std
::
string
&
name
=
StopwatchE
mptyString
());
/// Start with exception safety, then pause.
/// Start with exception safety, then pause.
/// Starts the Stopwatch and returns an object that, when goes out of scope,
/// Starts the Stopwatch and returns an object that, when goes out of scope,
/// pauses the watch. This allows Stopwatch to be started and paused in
/// pauses the watch. This allows Stopwatch to be started and paused in
/// an exception safe manner.
/// an exception safe manner.
Handler
startPause
(
const
std
::
string
&
name
=
e
mptyString
());
Handler
startPause
(
const
std
::
string
&
name
=
StopwatchE
mptyString
());
};
};
inline
inline
...
...
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