-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues in Aux::Timer #368
Conversation
I think we should just remove the virtual methods. Given that the methods return
|
a9e0dbc
to
2150c3a
Compare
* to exist until the end of the scope. If the time measured seems too short, make you created | ||
* a named instances. | ||
*/ | ||
class ScopedTimer : public StartedTimer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class has no users. Do we need it? When / how will users be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider this a developing tool. I typically have a copy of this class in my source tree and remove it before pushing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, would you consider renaming it to something like DebuggingTimer
/ DevelopmentTimer
/ LoggingTimer
(or some bikesheded version of that)?
* to exist until the end of the scope. If the time measured seems too short, make you created | ||
* a named instances. | ||
*/ | ||
class ScopedTimer : public StartedTimer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, would you consider renaming it to something like DebuggingTimer
/ DevelopmentTimer
/ LoggingTimer
(or some bikesheded version of that)?
* | ||
* @warning Similarly as std::unique_lock the timer needs a name ("someName" in the example) | ||
* to exist until the end of the scope. If the time measured seems too short, make you created | ||
* a named instances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I first I thought you were referring to the label. name
-> named variable
.
networkit/cpp/auxiliary/Timer.cpp
Outdated
|
||
ss << "ran for " << (elapsedMicroseconds() * 1e-3) << " ms"; | ||
|
||
std::cout << ss.str() << std::endl; // we really want to flush here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use NetworKit's logging framework, e.g., INFO()
.
The documentation said that elapsed*() methods returned the time elapsed since the start and now (if Timer is still running) or between start and stop if the Timer was stopped. elapsed() and elapsedMilliseconds() behaved that way, while elapsedMicroseconds() and elapsedNanoseconds() only considered stop. Also added const and nothrow where applicable.
Thanks for your feedback. For a proper
To do so, I added two functions to
Note that based on One "bug" the current solution has is that it will print the line number of the LoggingTimer's destructor if The PR also contains a mini-bugfix for a recently introduced signed/unsigned comparison; let me know, if I should separate it into its own PR. (BTW: The diff of the force-push only is that large because I rebased to current Dev) |
Thank you for the revision. The |
Clang rightfully complained about
Aux::Timer
not having a virtual destructor.While fixing this, I spotted a number of additional issues, justifying a PR on its own.This PR includes:
const
andnothrow
(where applicable)elapsedMicroseconds()
andelapsedNanoseconds()
: The documentation stated thatelapsed*()
methods returned the time elapsed since the start and now (if Timer is still running) orbetween start and stop if the Timer was stopped.
elapsed()
andelapsedMilliseconds()
behaved that way, whileelapsedMicroseconds()
andelapsedNanoseconds()
only considered the latter case.my_steady_clock
. While this should have been ausing
declaration not polluting global namespace.StartedTimer
which is identical toTimer
but does automatically callstart()
on construction.Remarks:
std::chrono::monotonic_clock
std::chrono::duration
in integer milliseconds seems strange; but we cannot really change that now.