Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
qpong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Co
qpong
Commits
9be59975
Commit
9be59975
authored
Jan 9, 2021
by
Armin Co
Browse files
Options
Downloads
Patches
Plain Diff
Timer class for profiling
parent
4d3498eb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
GuiCore/Timer.cpp
+34
-0
34 additions, 0 deletions
GuiCore/Timer.cpp
GuiCore/Timer.hpp
+32
-0
32 additions, 0 deletions
GuiCore/Timer.hpp
with
66 additions
and
0 deletions
GuiCore/Timer.cpp
0 → 100644
+
34
−
0
View file @
9be59975
/// @file Timer.cpp
/// @author Armin Co
///
#include
"Timer.hpp"
#include
"Log.hpp"
using
namespace
GuiCore
;
Timer
::
Timer
(
const
char
*
name
)
:
m_name
{
name
}
{
m_startTimepoint
=
std
::
chrono
::
high_resolution_clock
::
now
();
}
Timer
::~
Timer
()
{
stop
();
}
double
Timer
::
stop
()
{
auto
endTimepoint
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
start
=
std
::
chrono
::
time_point_cast
<
std
::
chrono
::
microseconds
>
(
m_startTimepoint
).
time_since_epoch
().
count
();
auto
end
=
std
::
chrono
::
time_point_cast
<
std
::
chrono
::
microseconds
>
(
endTimepoint
).
time_since_epoch
().
count
();
auto
duration
=
end
-
start
;
double
ms
=
duration
*
0.001
;
Log
::
get
()
->
debug
(
"{0}: {1}ms"
,
m_name
,
ms
);
return
ms
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
GuiCore/Timer.hpp
0 → 100644
+
32
−
0
View file @
9be59975
/// @file Timer.hpp
/// @author Armmin Co
///
#ifndef GUI_CORE_TIMER_HPP
#define GUI_CORE_TIMER_HPP
#include
<chrono>
namespace
GuiCore
{
class
Timer
{
public:
/// @brief Start timer
///
Timer
(
const
char
*
name
=
"Timer"
);
/// @brief Stops timer.
~
Timer
();
double
stop
();
private:
std
::
chrono
::
time_point
<
std
::
chrono
::
high_resolution_clock
>
m_startTimepoint
;
const
char
*
m_name
;
};
}
#endif
\ No newline at end of file
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