@@ -20,15 +20,14 @@ struct TraceContentView: View {
20
20
var tracer : OTTracer { Tracer . shared ( ) }
21
21
22
22
private let queue1 = DispatchQueue ( label: " com.datadoghq.benchmark-tracing1 " )
23
- private let queue2 = DispatchQueue ( label: " com.datadoghq.benchmark-tracing2 " )
24
23
25
24
init ( ) {
26
25
operationName = " iOS Benchmark span operation "
27
26
resourceName = " iOS Benchmark span resource "
28
27
isError = false
29
28
depth = 1
30
29
childrenCount = 0
31
- childDelay = 1
30
+ childDelay = 100
32
31
traceCount = 0
33
32
isSending = false
34
33
}
@@ -67,13 +66,13 @@ struct TraceContentView: View {
67
66
}
68
67
69
68
HStack {
70
- Text ( " Child delay: " )
69
+ Text ( " Child delay (ms) : " )
71
70
Spacer ( )
72
71
TextField ( " Child delay: " , value: $childDelay, formatter: NumberFormatter ( ) )
73
72
. textFieldStyle ( RoundedBorderTextFieldStyle ( ) )
74
73
. frame ( width: 80 )
75
74
. keyboardType ( . numberPad)
76
- Stepper ( " " , value: $childDelay, in: 1 ... 100 , step: 1 )
75
+ Stepper ( " " , value: $childDelay, in: 50 ... 10_000 , step: 50 )
77
76
. frame ( width: 80 )
78
77
}
79
78
}
@@ -128,13 +127,11 @@ struct TraceContentView: View {
128
127
)
129
128
}
130
129
131
- wait ( seconds : 0.5 )
130
+ Thread . sleep ( forTimeInterval : childDelay / 1_000 )
132
131
133
- queue2. sync {
134
- sendSpanTree ( parent: rootSpan, currentLevel: 0 , maxDepth: depth)
135
- }
132
+ sendSpanTree ( parent: rootSpan, currentLevel: 0 , maxDepth: depth)
136
133
137
- wait ( seconds : 0.5 )
134
+ Thread . sleep ( forTimeInterval : 0.5 )
138
135
rootSpan. finish ( )
139
136
140
137
DispatchQueue . main. async {
@@ -156,16 +153,13 @@ struct TraceContentView: View {
156
153
for i in 1 ... childrenCount {
157
154
let childOperation = " \( operationName) - Child \( i) at level \( currentLevel + 1 ) "
158
155
let childSpan = tracer. startSpan ( operationName: childOperation, childOf: parent. context)
159
- wait ( seconds: childDelay)
156
+
157
+ Thread . sleep ( forTimeInterval: childDelay / 1_000 )
160
158
161
159
sendSpanTree ( parent: childSpan, currentLevel: currentLevel + 1 , maxDepth: maxDepth)
162
160
childSpan. finish ( )
163
161
}
164
162
}
165
-
166
- private func wait( seconds: TimeInterval ) {
167
- Thread . sleep ( forTimeInterval: seconds)
168
- }
169
163
}
170
164
171
165
#Preview {
0 commit comments