DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
Stopwatch.h
Go to the documentation of this file.
1#pragma once
2
3#include "Common.h"
4#include "System/Object.h"
5#include "System/TimeSpan.h"
8
9namespace DotNetDupe {
10 namespace System {
11 namespace Diagnostics {
13
21 class Stopwatch : public Object {
22 public:
25
28 DOTNETDUPE_API Stopwatch(const TimeProviderPtr& timeProvider);
29
32
34 DOTNETDUPE_API void Start();
35
37 DOTNETDUPE_API void Stop();
38
40 DOTNETDUPE_API void Reset();
41
44
47 DOTNETDUPE_API bool IsRunning() const;
48
52
55 DOTNETDUPE_API long long ElapsedMilliseconds() const;
56
59 DOTNETDUPE_API long long ElapsedTicks() const;
60
64
68 DOTNETDUPE_API static Stopwatch StartNew(const TimeProviderPtr& timeProvider);
69
72 DOTNETDUPE_API static long long GetTimestamp();
73
75 DOTNETDUPE_API static const long long Frequency;
76
79
80 private:
81 struct Impl;
83
84 long long GetRawElapsedTicks() const;
85 };
86 }
87 }
88}
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
Provides an abstraction for time, timestamps, and elapsed time calculation.
Represents a time interval.
bool IsRunning() const
Gets a value indicating whether the Stopwatch timer is running.
Definition Stopwatch.cpp:76
TimeSpan Elapsed() const
Gets the total elapsed time measured by the current instance.
Definition Stopwatch.cpp:80
long long ElapsedMilliseconds() const
Gets the total elapsed time measured by the current instance, in milliseconds.
Definition Stopwatch.cpp:85
long long ElapsedTicks() const
Gets the total elapsed time measured by the current instance, in timer ticks.
Definition Stopwatch.cpp:90
static const bool IsHighResolution
Indicates whether the timer is based on a high-resolution performance counter.
Definition Stopwatch.h:78
void Reset()
Stops time measurement and resets the elapsed time to zero.
Definition Stopwatch.cpp:62
static Stopwatch StartNew()
Initializes a new Stopwatch instance, sets the elapsed time property to zero, and starts measuring el...
static const long long Frequency
Gets the frequency of the timer as the number of ticks per second.
Definition Stopwatch.h:75
void Restart()
Stops time measurement, resets the elapsed time to zero, and starts measuring elapsed time.
Definition Stopwatch.cpp:69
static long long GetTimestamp()
Gets the current number of ticks in the timer mechanism.
void Stop()
Stops measuring elapsed time for an interval.
Definition Stopwatch.cpp:53
~Stopwatch() override
Destructor releasing stopwatch resources.
Stopwatch()
Initializes a new instance of the Stopwatch class.
Definition Stopwatch.cpp:33
void Start()
Starts, or resumes, measuring elapsed time for an interval.
Definition Stopwatch.cpp:45
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents a time interval (duration of time or elapsed time) measured as a positive or negative numb...
Definition TimeSpan.h:20
SmartPointer< TimeProvider > TimeProviderPtr
Definition Stopwatch.h:12