CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
stopwatch.h
1
2#ifndef _stopwatch_h
3#define _stopwatch_h
4
5#include <system/object.h>
6#include <system/timespan.h>
7
8
9#ifdef ASPOSECPPLIB_BEING_BUILT
10#include <boost/chrono.hpp>
11#endif
12
13
14namespace System { namespace Diagnostics
15{
16 namespace Detail {
18 ASPOSECPP_3RD_PARTY_TYPE_HOLDER_HIDDEN_TYPE(boost::chrono::high_resolution_clock::time_point, time_point, sizeof(long long), long long, TimePointHolder);
19 }
20
21
22class Stopwatch;
25
30class ASPOSECPP_SHARED_CLASS Stopwatch : public System::Object
31{
33 RTTI_INFO(System::Diagnostics::Stopwatch, ::System::BaseTypesInfo<System::Object>)
34
35public:
37 ASPOSECPP_SHARED_API Stopwatch();
39 virtual ASPOSECPP_SHARED_API ~Stopwatch();
40
42 ASPOSECPP_SHARED_API void Start();
44 ASPOSECPP_SHARED_API void Stop();
46 ASPOSECPP_SHARED_API void Reset();
48 ASPOSECPP_SHARED_API void Restart();
51 bool get_IsRunning() const { return m_is_running; }
54 ASPOSECPP_SHARED_API TimeSpan get_Elapsed() const;
57 int64_t get_ElapsedMilliseconds() const { return static_cast<int64_t>(get_Elapsed().get_TotalMilliseconds()); }
60 int64_t get_ElapsedTicks() const { return get_ElapsedMilliseconds() * TimeSpan::TicksPerMillisecond; }
61
64 ASPOSECPP_SHARED_API static SharedPtr<Stopwatch> StartNew();
65
66private:
68 bool m_is_running;
70 Detail::TimePointHolder m_start;
72 TimeSpan m_elapsed;
73};
74
75} } // namespace System::Diagnostics
76#endif // _stopwatch_h
Allows time measurement. Objects of this class should only be allocated using System::MakeObject() fu...
Definition: stopwatch.h:31
int64_t get_ElapsedMilliseconds() const
Gets the total elapsed time measured by the current instance, in milliseconds.
Definition: stopwatch.h:57
void Start()
Starts time measurement.
static SharedPtr< Stopwatch > StartNew()
Creates new Stopwatch object and starts measurement.
bool get_IsRunning() const
Checks if stopwatch is running.
Definition: stopwatch.h:51
TimeSpan get_Elapsed() const
Gets the total elapsed time measured by the current instance.
void Stop()
Stops time measurement.
int64_t get_ElapsedTicks() const
Gets the total elapsed time measured by the current instance, in timer ticks.
Definition: stopwatch.h:60
Stopwatch()
RTTI information.
void Restart()
Sets measured interval to zero, then starts time measurement.
virtual ~Stopwatch()
Destructor.
void Reset()
Stops time measurement, sets measured interval to zero.
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Represents a time interval. This type should be allocated on stack and passed to functions by value o...
Definition: timespan.h:59
static constexpr int64_t TicksPerMillisecond
The number of 100-nanoseconds intervals in a millisecond.
Definition: timespan.h:73
SharedPtr< Stopwatch > StopwatchPtr
Pointer type.
Definition: stopwatch.h:24
Definition: db_command.h:9