@@ -165,7 +165,7 @@ public async Task MakeRequest([FromService] IConfiguration configuration, string
165
165
} ;
166
166
wsClient . SendHelloMessage ( hello ) ;
167
167
168
- _ = PrintingTaskLoopAsync ( wsClient , endpoint_name , subscribe_data_type , asset , symbol , exchange , latency_type ) ;
168
+ _ = PrintingTaskLoopAsync ( wsClient , endpoint_name , subscribe_data_type , asset , symbol , exchange , supress_hb , latency_type ) ;
169
169
170
170
await Task . Run ( ( ) => Console . ReadKey ( ) ) ;
171
171
}
@@ -202,7 +202,7 @@ private void ProcessMsg(DateTime? time_exchange, DateTime? time_coinapi, Latency
202
202
203
203
private async Task PrintingTaskLoopAsync ( CoinApiWsClient wsClient ,
204
204
string endpoint_name , string subscribe_data_type , string asset ,
205
- string symbol , string exchange , string latency_type )
205
+ string symbol , string exchange , bool supress_hb , string latency_type )
206
206
{
207
207
var iterations = 0 ;
208
208
Serilog . Log . Information ( $ "Time: { DateTime . UtcNow } ") ;
@@ -225,7 +225,32 @@ private async Task PrintingTaskLoopAsync(CoinApiWsClient wsClient,
225
225
226
226
Serilog . Log . Information ( strbld . ToString ( ) ) ;
227
227
228
- var process = Process . GetCurrentProcess ( ) ;
228
+ string basePath = "output" ;
229
+ string extension = ".csv" ;
230
+
231
+ string csvFilePath = basePath + extension ;
232
+ int counter = 1 ;
233
+
234
+ while ( File . Exists ( csvFilePath ) )
235
+ {
236
+ csvFilePath = $ "{ basePath } _{ counter } { extension } ";
237
+ counter ++ ;
238
+ }
239
+
240
+ using ( StreamWriter sw = File . CreateText ( csvFilePath ) )
241
+ {
242
+ sw . WriteLine ( "Parameters:" ) ;
243
+ sw . WriteLine ( $ "Endpoint Name: { endpoint_name } ") ;
244
+ sw . WriteLine ( $ "Subscribe Data Type: { subscribe_data_type } ") ;
245
+ sw . WriteLine ( $ "Asset: { asset } ") ;
246
+ sw . WriteLine ( $ "Symbol: { symbol } ") ;
247
+ sw . WriteLine ( $ "Exchange: { exchange } ") ;
248
+ sw . WriteLine ( $ "Supress heartbeat: { supress_hb } ") ;
249
+ sw . WriteLine ( $ "Latency type: { latency_type } ") ;
250
+ sw . WriteLine ( ) ;
251
+ sw . WriteLine ( "Timestamp;Messages;BytesReceived;WaitingCPU%;ParsingCPU%;ProcessingCPU%;LatencyMin(ms);LatencyMax(ms)" ) ;
252
+ }
253
+
229
254
230
255
while ( true )
231
256
{
@@ -276,7 +301,7 @@ private async Task PrintingTaskLoopAsync(CoinApiWsClient wsClient,
276
301
277
302
strbld . AppendFormat ( $ "Messages: { msgCountOnInterval , - 8 } ") ;
278
303
strbld . AppendFormat ( $ "| Recv bytes: { bytesCountOnInterval , - 8 } ") ;
279
- strbld . Append ( $ "| CPU: wait: { cpuWaitingPercent : F2 } % | parse: { cpuParsingPercent : F2 } % | process: { cpuHandlingPercent : F2 } % ") ;
304
+ strbld . Append ( $ "| CPU: wait: { cpuWaitingPercent : P } | parse: { cpuParsingPercent : P } | process: { cpuHandlingPercent : P } ") ;
280
305
281
306
if ( latencies . Any ( ) )
282
307
{
@@ -285,6 +310,12 @@ private async Task PrintingTaskLoopAsync(CoinApiWsClient wsClient,
285
310
}
286
311
287
312
Serilog . Log . Information ( strbld . ToString ( ) ) ;
313
+
314
+ using ( StreamWriter sw = File . AppendText ( csvFilePath ) )
315
+ {
316
+ sw . WriteLine ( $ "\" { DateTime . UtcNow : yyyy-MM-dd HH:mm:ss} \" ;{ msgCountOnInterval } ;{ bytesCountOnInterval } ;{ cpuWaitingPercent : F2} ;{ cpuParsingPercent : F2} ;{ cpuHandlingPercent : F2} ;{ ( latencies . Any ( ) ? latencies . Min ( ) . TotalMilliseconds : 0 ) : F2} ;{ ( latencies . Any ( ) ? latencies . Max ( ) . TotalMilliseconds : 0 ) : F2} ") ;
317
+ }
318
+
288
319
}
289
320
}
290
321
0 commit comments