@@ -40,7 +40,6 @@ public protocol SwiftDistributedTracingInstantProtocol: Comparable, Hashable, Se
40
40
41
41
public protocol TracerInstantProtocol : SwiftDistributedTracingInstantProtocol {
42
42
/// Representation of this instant as the number of milliseconds since UNIX Epoch (January 1st 1970)
43
- @inlinable
44
43
var millisecondsSinceEpoch : UInt64 { get }
45
44
}
46
45
@@ -64,7 +63,6 @@ public protocol TracerClock {
64
63
/// A basic "timestamp clock" implementation that is able to five the current time as an unix timestamp.
65
64
public struct DefaultTracerClock : TracerClock {
66
65
public typealias Instant = Timestamp
67
- internal typealias TimeInterval = Double
68
66
69
67
public init ( ) {
70
68
// empty
@@ -107,78 +105,3 @@ public struct DefaultTracerClock: TracerClock {
107
105
return Instant ( millisecondsSinceEpoch: nowMillis)
108
106
}
109
107
}
110
-
111
- #if swift(>=5.7.0)
112
- @available ( macOS 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * )
113
- extension Duration {
114
- typealias Value = Int64
115
-
116
- var nanoseconds : Value {
117
- let ( seconds, attoseconds) = self . components
118
- let sNanos = seconds * Value( 1_000_000_000 )
119
- let asNanos = attoseconds / Value( 1_000_000_000 )
120
- let ( totalNanos, overflow) = sNanos. addingReportingOverflow ( asNanos)
121
- return overflow ? . max : totalNanos
122
- }
123
-
124
- /// The microseconds representation of the `TimeAmount`.
125
- var microseconds : Value {
126
- self . nanoseconds / TimeUnit. microseconds. rawValue
127
- }
128
-
129
- /// The milliseconds representation of the `TimeAmount`.
130
- var milliseconds : Value {
131
- self . nanoseconds / TimeUnit. milliseconds. rawValue
132
- }
133
-
134
- /// The seconds representation of the `TimeAmount`.
135
- var seconds : Value {
136
- self . nanoseconds / TimeUnit. seconds. rawValue
137
- }
138
-
139
- var isEffectivelyInfinite : Bool {
140
- self . nanoseconds == . max
141
- }
142
- }
143
-
144
- @available ( macOS 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * )
145
- extension Duration {
146
- private func chooseUnit( _ ns: Value ) -> TimeUnit {
147
- if ns / TimeUnit. seconds. rawValue > 0 {
148
- return TimeUnit . seconds
149
- } else if ns / TimeUnit. milliseconds. rawValue > 0 {
150
- return TimeUnit . milliseconds
151
- } else if ns / TimeUnit. microseconds. rawValue > 0 {
152
- return TimeUnit . microseconds
153
- } else {
154
- return TimeUnit . nanoseconds
155
- }
156
- }
157
-
158
- /// Represents number of nanoseconds within given time unit
159
- enum TimeUnit : Value {
160
- case seconds = 1_000_000_000
161
- case milliseconds = 1_000_000
162
- case microseconds = 1000
163
- case nanoseconds = 1
164
-
165
- var abbreviated : String {
166
- switch self {
167
- case . nanoseconds: return " ns "
168
- case . microseconds: return " μs "
169
- case . milliseconds: return " ms "
170
- case . seconds: return " s "
171
- }
172
- }
173
-
174
- func duration( _ duration: Int ) -> Duration {
175
- switch self {
176
- case . nanoseconds: return . nanoseconds( Value ( duration) )
177
- case . microseconds: return . microseconds( Value ( duration) )
178
- case . milliseconds: return . milliseconds( Value ( duration) )
179
- case . seconds: return . seconds( Value ( duration) )
180
- }
181
- }
182
- }
183
- }
184
- #endif
0 commit comments